https://github.com/rbw/records-old
Example Starlette REST API application
https://github.com/rbw/records-old
Last synced: 3 months ago
JSON representation
Example Starlette REST API application
- Host: GitHub
- URL: https://github.com/rbw/records-old
- Owner: rbw
- License: mit
- Created: 2021-07-28T09:19:09.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-12-30T23:59:45.000Z (over 4 years ago)
- Last Synced: 2025-10-29T06:31:55.027Z (8 months ago)
- Language: Python
- Homepage:
- Size: 248 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
The idea of this project is to show how Starlette, Marshmallow,
and SQLAlchemy can be combined to create a RESTful HTTP API
application that is modular, lightweight, and capable of dealing
with many simultaneous requests.
## Setting up
Requires Python 3.9+, git, and poetry.
### Building
```
$ git clone https://github.com/rbw/records.git
$ cd records
$ poetry update
```
### Starting Postgres
The application requires an SQLAlchemy-supported relational database. This example uses pg.ARRAY in AlbumModel, making it compatible with Postgres only.
A docker-compose file for running a Postgres server is available in the project root.
```
$ docker-compose up
```
### Starting Records
```
$ poetry shell
$ python -m records
```
## Usage
### Get all albums
```
$ curl http://localhost:5000/albums
```
### Create an album
```
$ curl -X POST --data '{"title": "test", "release_date": "2035-01-20", "stores": ["APPLE", "YOUTUBE"], "tracks": ["TEST000000001", "TEST000000002"], "upc": "00000000000005"}' http://localhost:5000/albums
```
### Show an album
```
$ curl http://localhost:5000/albums/00000000000005
```
## Todo
- Add Tracks API `[GET/POST/DELETE => /tracks,/tracks:trackid:]`
- Implement add-tracks-to-album `[POST => /albums/:albumid:/tracks]`
- Implement del-track-from-album `[DELETE => /albums/:albumid:/tracks/:trackid:]`
- Implement query filtering
- Add CLI
- Project docs
- Code docs
- Automated tests
## Funding
Consider [leaving a donation](https://paypal.vault13.org) if you like this software.
## Author
Robert Wikman \