Will via plug on 12 Apr 2022 12:09:02 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Resources: Python REST client?


Here is a 1 page simple Python Flask API example I use for teaching. 

https://gitlab.com/cluelesscoders1/randomprojects/flask-api-simple

-Will C

On Tue, Apr 12, 2022 at 2:09 PM Walt Mankowski via plug <plug@lists.phillylinux.org> wrote:
On Tue, Apr 12, 2022 at 01:44:06PM -0400, brent timothy saner via plug wrote:
> On 4/12/22 13:37, JP Vossen via plug wrote:
> > We have some open tickets at $WORK involving writing some Python code to
> > interact with various REST APIs, notably Jira/Insight and
> > Elasticsearch/Kibana.  Is anyone aware of a good "Building REST API
> > clients in Python" book or resource?  There are tons of books on doing
> > the server side--that is, writing the server and API part in Python. 
> > But I'm having trouble finding the opposite.
> >
> > Clues?  Thanks.
> > JP
>
> The requests module is usually pretty good for it.
>
> https://www.nylas.com/blog/use-python-requests-module-rest-apis/ gives
> you a good overview, but surprisingly most third-party resources don't
> go into requests.Session[0] - which is perfect for API usage.
>
> If you subclass[1] to use a base URI, you can use relative URLs for your
> API endpoints directly (and can more easily manage a variabled domain name).
>
>
>
> [0]
> https://docs.python-requests.org/en/master/user/advanced/#session-objects
>
> [1] https://github.com/psf/requests/issues/2554#issuecomment-109341010
>
> https://stackoverflow.com/questions/42601812/python-requests-url-base-in-session

There's also an Elasticsearch module for Python: https://elasticsearch-py.readthedocs.io/en/v8.1.2/

Walt
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug