-
-
Notifications
You must be signed in to change notification settings - Fork 759
API documentation
This page describes Open Food Network's API. It is based on Spree's API, which has extensive documentation (source). See also spree-api's routes.rb.
The Open Food Network API is not finished. Entries that are crossed out
are candidates for addition.
- Products, their properties and Variants;
- Orders, Line items and Checkouts;
- Payments, Shipments and Return authorizations;
- Taxonomies, Addresses, Countries and Zones;
- Stock Locations and Stock movements.
- Enterprises
- Order cycles
- The managed scope for Products and Orders, Enterprises and Order cycles;
- A soft_delete action on Products and Variants;
To access the API, you need an API key. This can be found in the admin
backend at the right of the edit user page. That can be passed with the
X-Spree-Token header, or the token parameter.
Read more.
If you want to verify programmatically that you have a valid token, the
/api/users/authorise_api endpoint will return on success:
{
"success": "Use of API Authorised"
}GET /api/enterprises- returns a list of all enterprises-
GET /api/enterprises/managed- returns a list of enterprises the user manages GET /api/enterprises/accessible- returns a list of the user has access toPOST /api/enterprises- creates a new enterprisePUT /api/enterprises/:id- updates an enterpriseDELETE /api/enterprises/:id- deletes an enterprise
Returns a list of enterprises the user manages.
[
{
id: 1,
name: "Enterprise 1"
}
...
]
Returns the list of order cycles of enterprises the user manages.
[
{
id: 1,
name: "Winter season",
first_order: "2015-11-01",
last_order: "2015-12-04",
suppliers: [
{
id: 2,
name: "Enterprise 2"
}
],
distributors: [
{
id: 15,
name: "The Basket"
}
]
},
...
]
Returns the list of order cycles that are accessible to the user.
The optional parameter as can either distributor or producer
and will filter the list to the user's distributor- or producer-role
respectively.
In Open Food Network users can manage enterprises, and it can be useful to retrieve a list of enterprises, orders, order cycles and products that the user accessing the api manages. Open Food Network includes an additional scope for those:
GET /api/products/managedGET /api/orders/managedGET /api/order_cycles/managedGET /api/enterprises/managed
They work just like the regular index, except filter the results to those the user can manage. The products index has some additional scopes:
-
GET /api/products/bulk_products- products that require group buying -
GET /api/products/overridable- TODO explain
Products and variants can also be soft-deleted in Open Food Network. This is done with the endpoints
TODO Explain what and why of soft-deletion.
DELETE /api/products/:product_id/soft_deleteDELETE /api/products/:product_id/variants/:variant_id/soft-delete
Development environment setup
- Pipeline development process
- Bug severity
- Feature template (epic)
- Internationalisation (i18n)
- Dependency updates
Development
- Developer Guidelines
- The process of review, test, merge and deploy
- Making a great commit
- Making a great pull request
- Code Conventions
- Database migrations
- Testing and Rspec Tips
- Testing GitHub Actions Locally with act
- Automated Testing Gotchas
- Rubocop
- Angular and OFN
- Feature toggles
- Stimulus and Turbo
Testing
- Testing process
- OFN Testing Documentation (Handbooks)
- Continuous Integration
- Parallelized test suite with knapsack
- Karma
Releasing
Specific features
Data and APIs
- API documentation
- Authentication
- Integration & API
- Data migration
- Data model diagram (ERD)
- Stripe
- DFC Guide
Instance-specific configuration
External services
Design