API Series #2 - Building an API with Flask in Python

preview_player
Показать описание

How can we set up a way to communicate from one software instance to another? It sounds simple, and - to be completely honest - it is.

All we need is an API.

An API (Application Programming Interface) is a simple interface that defines the types of requests (demands/questions, etc.) that can be made, how they are made, and how they are processed.

In our case, we will be building an API that allows us to send a range of GET/POST/PUT/PATCH/DELETE requests (more on this later), to different endpoints, and return or modify data connected to our API.

We will be using the Flask framework to create our API and Insomnia to test it.

🤖 70% Discount on the NLP With Transformers in Python course:

🕹️ Medium article:

🎉 Subscribe for Article and Video Updates!

👾 Discord:

Free article link:

Download Insomnia:
Рекомендации по теме
Комментарии
Автор

I agree with everyone that this video is awesome. However, if you're on linux, I found that I had to add location='values' to the parser.add_argument method calls in the post method -> parser.add_argument('userId', required=True, location='values') . Once I did that, problems solved. The message that I was getting was "{ "message": "Did not attempt to load JSON data because the request Content-Type was not 'application/json'." }"

thomives
Автор

Thank you every much for easy practice, it’s help me a lot to conclude how flask-rest API works. Keep it up!!

JummaJara
Автор

This was short, sweet and exactly what I was looking for. Thank you!!

prafulmaka
Автор

Hi, James, thank you for the practice. I have a question. The post method works great at 127..0.0.1:5000. However, when I deployed the python flask to IIS, the post method is not working at localhost:port/users?…not sure if I miss anything.

ikeandmama
Автор

Bro, you are an Angel for me, Finally, I learn how to make an API after a couple of months I waste.

zindamayat
Автор

Thanks James, the TDS article is excellent. Having the article to go with the video is really useful👍

python
Автор

Hello! I'm following along and just finished the POST method, but whenever I try to do the command I get a 400 error, even after copy/pasting the code from the article. Help?

wilrulez
Автор

Well explained! Looking forward to part 3.

harryayce
Автор

18:24 gave me an error without adding location='args' to parser.add_argument().

sascha.
Автор

Thanks a lot for this explanation, very clear and will save me a lot of time!

MrLeMarius
Автор

Getting this error trying to run the code
"Object of type method is not JSON serializable"
the error is coming from this line
return {'data': data}, 200
because the data prints correctly just before this

rmunson
Автор

Hey! So I wanna build an API with GET and POST methods and with access tokens or API keys. I want to limit functionality of certain keys to only the GET method while some should be able to do both. Can you tell me how I can do that securely?

mrunalsonawane
Автор

Is there any difference between REST APIs written in Python or others.
Like, can we call Python API from Flutter Android app. Is that be a good practice?

stangerdanger
Автор

how to get/post data from/to sql server instead of csv file ?

nabeelahmed
Автор

hi james. is there a flask library for graphql ?

bnproduction
Автор

Hi there, is this an example of a REST API?

veroniquereagon
welcome to shbcf.ru