Skip to content
/ api Public

An authenticated API for the OCF.

License

Notifications You must be signed in to change notification settings

ocf/api

Repository files navigation

OCF API

An authenticated API for the OCF.

Developing locally

make dev

Running tests

make test

Testing

FastAPI endpoints

The deployed (master) version can be accessed at https://api.ocf.berkeley.edu/docs. Accordingly, if you are running this locally using the command above, you can access a similarly fancy dashboard at localhost:8000/docs.

You can even test authenticated endpoints by logging in on that page with OCF Keycloak SSO. Use a client_id of ocfstatic and a blank client secret, and it should log you in.

Test setup with ocfstatic (and perhaps other projects too)

Since this API is being used increasingly in the ocfstatic project, here's how to get them working together:

  1. Follow the steps to setup and run

  2. It's quite likely that you'll need to access mysql.ocf.berkeley.edu from your local machine to grab the data for your endpoints. This won't work immediately, so do the following:

    1. Go into the file ./venv/lib/python3.9/site-packages/ocflib/infra/mysql.py and change host to '127.0.0.1'
    2. Open an ssh tunnel to Supernova (staff server) so that these requests can actually go through on port 3306. Use the command: ssh <username>@supernova.ocf.berkeley.edu -L 3306:mysql:3306

    At this point you should be able to locally access custom endpoints that use mysql.ocf.berkeley.edu.

  3. To test integration with ocfstatic, you have to point requests at the API, most likely http://127.0.0.1:8000, or the port specified by uvicorn.