usaspending-api | Server application to serve US federal spending data via a RESTful API | REST library
kandi X-RAY | usaspending-api Summary
kandi X-RAY | usaspending-api Summary
Server application to serve U.S. federal spending data via a RESTful API
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Return a set of business categories
- Returns a queryset with the given filters .
- Handles an exit signal .
- Returns the Subaward filter queryset .
- Handles custom award download .
- Validate a type filter .
- Updates the db for all transactions in the Broker DB .
- Add awards to derived_fields .
- Gets the file b .
- Delete documents by the given key .
usaspending-api Key Features
usaspending-api Examples and Code Snippets
Community Discussions
Trending Discussions on usaspending-api
QUESTION
I'm a beginner and I'm getting a 422 error when running a code to extract data from an API endpoint. I Googled the code and realized it's an (Unprocessable Entity) status code, but I'm not sure how to fix it.
The documentation for the API is right here: https://github.com/fedspendingtransparency/usaspending-api/blob/master/usaspending_api/api_contracts/contracts/v2/search/spending_by_award.md
Can anyone please let me know how to modify my code?
...ANSWER
Answered 2021-May-29 at 03:46You may modify the data type of several fields, i.e., the award_ids
should be a array[string]
, recipient_locations
consists of array[LocationObject]
For a working example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install usaspending-api
Local Empty DB. Use your own local postgres database for the API to use.
Containerized Empty DB. Create an empty directory on your localhost where all the database files will persist and use the docker-compose file to bring up a containerized postgres database.
Local Populated DB. Download either the whole database or a database subset from the USAspending website.
Postgres Setup Help
Docker Compose
If you run a local database, set POSTGRES_HOST in .env to host.docker.internal. POSTGRES_PORT should be changed if it isn't 5432. docker-compose up usaspending-db will create and run a Postgres database. docker-compose run --rm usaspending-manage python3 -u manage.py migrate will run Django migrations: https://docs.djangoproject.com/en/2.2/topics/migrations/. docker-compose run --rm usaspending-manage python3 -u manage.py load_reference_data will load essential reference data (agencies, program activity codes, CFDA program data, country codes, and others). docker-compose run --rm usaspending-manage python3 -u manage.py matview_runner --dependencies will provision the materialized views which are required by certain API endpoints.
docker-compose.yaml contains the shell commands necessary to set up the database manually, if you prefer to have a more custom environment.
Some of the API endpoints reach into Elasticsearch for data.
docker-compose up usaspending-es will create and start a single-node Elasticsearch cluster, using the ES_CLUSTER_DIR specified in the .env configuration file. We recommend using a folder outside of the usaspending-api project directory so it does not get copied to other containers.
The cluster should be reachable via at http://localhost:9200 ("You Know, for Search").
Optionally, to see log output, use docker-compose logs usaspending-es (these logs are stored by docker even if you don't use this).
To run all USAspending tests in the docker services run.
Postgres A running PostgreSQL database server (See Database Setup above)
Elasticsearch A running Elasticsearch cluster (See Elasticsearch Setup above)
Required Python Libraries Python package dependencies downloaded and discoverable (See below)
Environment Variables Tell python where to connect to the various data stores (See below)
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page