APIs with Python - Intro with KillerCoda
Content aggregated and developed for the study about APIs
-
Create an Ubuntu instance in KillerCoda
-
Run This command on VM Terminal:
curl https://raw.githubusercontent.com/RafaelFino/learnops-api-python/main/prepare.sh | bash && zsh
- Run the command, for application path (~/learnops-api-python):
cd ~/learnops-api-python
source bin/activate
pip3 install -r requirements.txt
- Run command, to upload the server:
./run-server.sh {api-name}
If you run ./run-server.sh and don't provide the endpoint, you'll get the following return:
API name are expected! Try one of available options:
# ping
# example
# hello
# body
# sum
# crud
# currency
# auth
# auth-jwt
-
Open a second tab in the console, to run the client commands
-
Run command, for application path (~/learnops-api-python):
cd ~/learnops-api-python
source bin/activate
- Run the command to make the requests
./run-client.sh {api-name}
Name | Description | HTTP return | Swagger | Args | Return type | Diagram |
---|---|---|---|---|---|---|
ping | A ping pong example API | 𐄂 | 𐄂 | 𐄂 | text | ping diagram |
example | Simple API, using swagger | ✓ | in code | 𐄂 | json body | example diagram |
hello | API with one path GET method | ✓ | in file | in path | json body | hello diagram |
body | API with one POST method, passing args in body | ✓ | in file | in body | json body | body diagram |
sum | A sum calc API, to show a simple service | ✓ | in file | in body | json body | sum diagram |
crud | REST API with CRUD example, to show REST Methods | ✓ | indivual files | in body and path | json body | crud diagram |
currency | API to query and convert currency values, args on path and body | ✓ | indivual files | in body and path | json body | currency diagram |
auth | Simple API to show a how a login and token works | ✓ | indivual files | in body and header | json body | auth diagram |
auth-jwt | Login API example with JWT | ✓ | indivual files | in body, header and path | json body | auth-jwt diagram |
- Distributed Systems
- What is an API?
- HTTP Pattern
- REST APIs
- JSON Format
- Auth and Sec
- JWT - Json Web Token
- Micro Services and APIs
- Arch and best pratices
- API managed with Flask
- OpenAPI automated interface and Swagger with flasgger
- Sequence diagrams automated by seqdiag
- Currency data from economia.awesomeapi
- Awesome texts about JWT and how to handle it with Python by Jessica Temporal and Wellington Nascimento
- Table of contents made with extracttoc
- Python JWT examples made with pyjwt
- Python Criptografy examples made with cryptography
- An excelent and very complete article comparing APIs and Microservices from Durga Prasad Acharya
Thanks!