ourresearch / journalsdb

Open database of scholarly journals
https://journalsdb.org
MIT License
10 stars 0 forks source link

JournalsDB API

Update: As of September 2022 the JournalsDB API is no longer maintained.

This is the API for JournalsDB and is hosted at https://api.journalsdb.org

Developer Instructions

Setup

  1. pip install -r requirements.txt
  2. Set DATABASE_URL environment variable to point to a postgresql database
  3. Build database with command flask db upgrade
  4. Ingest initial data by running flask import_issns, followed by flask import_issn_apis (second command takes 6+ hours for initial load)

Ingest data

Ingest data using flask CLI commands. All ingest functions are stored in the /ingest directory.

To see a list of available cli commands:

$ flask
Commands:
  db                         Perform database migrations.
  import_author_permissions  Google sheet from...
  import_extension_requests  Extension requests:...
  import_issn_apis           Iterate over issn_metadata table, then fetch...
  import_issns               Master ISSN list:...
  import_open_access         Open access data:...
  import_repositories        Repository article counts:...

Database Migrations

Migrations are managed with flask-migrate.

Run the migration files to build the database:

$ flask db upgrade

View current migration status with:

$ flask db current

To create migrations for changed models:

$ flask db migrate -m "Add title field"

CORS

CORS is enabled for the entire project via flask-CORS.

Code Formatting

All code is formatted with black.

$ black .

Tests

You must point to a local postgresql database for testing, as sqlite does not support jsonb columsn. The default name is journalsdb_test.

Run tests with:

$ pytest