API service, library and parser for BBFC
Project description
BBFC API
Web API and Python library for BBFC.
High-Level REST Web API
To use the REST API to query BBFC, first run the web server:
$ uvicorn bbfcapi.apiweb:app
Then, to query the API using curl
:
$ curl "127.0.0.1:8000?title=interstellar&year=2014"
{"title":"INTERSTELLAR","year":2014,"age_rating":"12"}
Or, to query the API from another web page:
async function call()
{
const response = await fetch('http://127.0.0.1:8000/?title=interstellar&year=2014');
const responseJson = await response.json();
console.log(JSON.stringify(responseJson));
}
call();
Additional notes:
- HTTP 404 Not Found is returned when there is no film found.
- Browse documentation @ http://127.0.0.1:8000/redoc.
- Or, browse documentation @ http://127.0.0.1:8000/docs.
High-Level Python Library
To use the library to get results from BBFC asynchronously:
from bbfcapi.apilib import top_search_result
print(await top_search_result(title="interstellar", year=2014))
To use the library to get results from BBFC synchronously:
import asyncio
from bbfcapi.apilib import top_search_result
print(asyncio.run(top_search_result(title="interstellar", year=2014)))
Low-Level Python Library
To use the library to get raw HTML pages from BBFC asynchronously:
from bbfcapi import client
print(await client.search(title="interstellar", year=2014))
To use the library to get raw HTML pages from BBFC synchronously:
import asyncio
from bbfcapi import client
print(asyncio.run(client.search(title="interstellar", year=2014)))
To use the library to parse raw HTML pages from BBFC:
from bbfcapi import parser
print(parser.parse_top_search_result(b"<BBFC search page byte-string>"))
Development
poetry install
to set up the virtualenv (one-off)poetry run uvicorn bbfcapi.apiweb:app --reload
to run the web servermake fix
,make check
, andmake test
before committing
There is also make test-live
which will run live integration tests against
the BBFC website.
Contributing
Pull requests are welcome :)
Publishing
This application is published on PyPi.
- Ensure you have configured the PyPi repository with Poetry (one-off)
- Run
make release
to execute the check-list
To publish to the test repository:
- Ensure you have configured the Test PyPi repository with Poetry (one-off)
poetry publish --build -r testpypi
to upload to the test repository
Changelog
v1.0.0 - 2020-01-19
- First release of bbfcapi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bbfcapi-1.0.0.tar.gz
.
File metadata
- Download URL: bbfcapi-1.0.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.8.1 Linux/5.4.7-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 635b17c430e9b3242aba75cb00842dddea0a23c2c4dbeef59530d2ab7566c8a1 |
|
MD5 | f8bb6432bce55e1ae8ffdccf095f406f |
|
BLAKE2b-256 | 6628c8d857b34887f52c3ad9eb7faf96ef28c110be18b9fbda4eb445e7f2f037 |
File details
Details for the file bbfcapi-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: bbfcapi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.2 CPython/3.8.1 Linux/5.4.7-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf1b0d2ab058273c3564e034edf25a35c9ff13c6fdfdb3d79331aae82f566744 |
|
MD5 | 112aa97721f0e5729baad110bf3e780c |
|
BLAKE2b-256 | 77bc9c8de360ee2c7737ffb613df0021762715279ee45b16a1d838b410323ae0 |