Skip to main content

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:

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

  1. poetry install to set up the virtualenv (one-off)
  2. poetry run uvicorn bbfcapi.apiweb:app --reload to run the web server
  3. make fix, make check, and make 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.

  1. Ensure you have configured the PyPi repository with Poetry (one-off)
  2. Run make release to execute the check-list

To publish to the test repository:

  1. Ensure you have configured the Test PyPi repository with Poetry (one-off)
  2. poetry publish --build -r testpypi to upload to the test repository

Changelog

Unreleased

...

v1.0.1 - 2020-01-19

  • Fix parsing 12A age ratings

v1.0.0 - 2020-01-19

  • First release of bbfcapi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bbfcapi-1.0.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

bbfcapi-1.0.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file bbfcapi-1.0.1.tar.gz.

File metadata

  • Download URL: bbfcapi-1.0.1.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

Hashes for bbfcapi-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c6418fa54b9892767f735d490a1be1d0916ae57972d554507f279cae66032be9
MD5 e701b8bf1063fbf434118990a2228d38
BLAKE2b-256 3a01d0a094dfd8013727e5eb68d55b59fcc67bea4c0616fd1d4f6ab807c93933

See more details on using hashes here.

File details

Details for the file bbfcapi-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: bbfcapi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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

Hashes for bbfcapi-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c5550a2edbedbc627bd13aeb2621e8c7657338bf55c9010e180749c553db73df
MD5 558d05c13ff30d408fcc85efa1f6638a
BLAKE2b-256 c72041986b43ed2ea05d3704140db498ac04f849ae05df46cdad23006515edb2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page