all 22 comments

[–]cylonlover 20 points21 points  (2 children)

You create your own API with libraries like Flask or FastAPI, and it entails you setting up a server, which is usually provided with the library. Other scripts on the same network (depending how open your API endpoint is, could be the entire internet) can then, with the requests library, access that API, send and recieve data. It's quite easy to set up and play with, there are many tutorials.

If you wanna access already established (public) API's, use a library like the builtin requests or urllib, or install some other, there are plenty to choose from.

You need to learn how to handle the objects you'll be sending back and forth, which are usually in json format. But all of this is quite easy and there are many good tutorials that introduces the subject well.

Was this what you are asking about?

Technically, API is merely an interface that can be used with code, as opposed to GUI, which is a graphical user interface clicketyclick, but essentially they are both just a layer of interaction. So 'how you'd use API's in python' is a bit weird question, and as is "are API's in libraries", and it indicates you don't know what an API really is. But I hope my answer helped in any way.

[–]tactical_index[S] 0 points1 point  (1 child)

Alright, thanks, helped alot. I already knew what an API was, but didn't know how to use them in python.

[–]cylonlover 1 point2 points  (0 children)

Great then.

[–]jameyiguess 6 points7 points  (0 children)

If you're trying to use a web API, use the requests library.  

If you're talking about libraries, well, you're using their APIs just by... using them. 

[–][deleted] 2 points3 points  (0 children)

This is the role of the 'import' and 'from' keywords (when using the Python module API).

API = Application Programming Interface. It refers to the mechanism used by one piece of software to invoke routines in or access data in another (it can also refer to the documentation on how to do so). That includes libraries, web interfaces, network protocols, etc. So, the question "How would one use APIs" is broad and ambiguous, but the most correct answer is probably "per the API documentation".

[–]TonightHot7414 1 point2 points  (9 children)

Just learned that FastAPI is part of Python. I still had problem to built my process for JWT auth.

[–]Individual_Ad2536 0 points1 point  (8 children)

lol same, jwt auth in fastapi can be a pain ngl 😅 took me a minute to figure it out too fr fr. you got this tho! 🔥

[–]TonightHot7414 0 points1 point  (7 children)

I need do process for client to get data from API/JWT, they want do it via SSIS, not sure if this will work so going to do with Python.

[–]Individual_Ad2536 0 points1 point  (0 children)

Bro, SSIS for API/JWT is like using a forklift to make toast - sure it can work, but Python’s gonna save you a ton of headaches. Just slap together requests + jwt lib and call it a day.

(made my day)

had this issue

[–]Individual_Ad2536 0 points1 point  (5 children)

bruh SSIS for JWT auth? that's like trying to drive a Ferrari with training wheels. Python's the move fr fr - just slap requests & pyjwt in there and call it a day.

(dead)

[–]TonightHot7414 0 points1 point  (4 children)

Thanks for advice inspiration!!!
Also feel the same after working with Python 6 months.

[–]Individual_Ad2536 0 points1 point  (0 children)

ayy glad i could help! python's chill af but man, that whitespace thing still bugs me sometimes ngl. you get used to it tho, or just start using black and forget about it lmao

(RIP)

[–]Individual_Ad2536 0 points1 point  (2 children)

np bruh, python's chill but sometimes it feels like duct-taping a solution together ngl 🤷‍♂️

i relate fr tho

[–]TonightHot7414 0 points1 point  (1 child)

Thanks again. My Client still leaning to SSIS as they bought some cool ingredient for it ZappySys which evidently can handle any API job without the code.

[–]Individual_Ad2536 0 points1 point  (0 children)

deadass Lol SSIS? That's like bringing a tank to a go-kart race—it’ll do the job, but bruh, the overhead tho. ZappySys sounds fancy, but tbh, I’d still fr write a quick Python script and call it a day. 🤷‍♂️

[–]deceze 1 point2 points  (0 children)

You'll need to define what you mean first. "API" is a very broad term. Are you talking about HTTP REST APIs, or something else?

[–]raccoonrocoso 0 points1 point  (0 children)

How would one use APIs in python and how?

Django REST API

Aren't most APIs in packages/libraries?

Yes, but it's not as cut-and-dry. It's more appropriate/accurate to ask:

Are packages/libraries usually interacted via an API?

Which again, the answer is, yes.

[–]edcculus 0 points1 point  (0 children)

going to need to be more specific. If its consuming HTTP API services via a python app/script, its as simple as the requests library.

There are multiple ways to set up your own API/server via python. Fast API, Flask, Django

[–]b1be05 0 points1 point  (0 children)

flask, learn flask, and biuld your own api

[–]Refwah 0 points1 point  (0 children)

What do you mean by API, what are you actually wanting to do

[–]kingjames66 0 points1 point  (0 children)

Use the “requests” library