Answer the question
In order to leave comments, you need to log in
How to organize getting a list of valid parameter values from the API?
Hi
Need to design an API.
Prompt, how to transfer to the client the list of possible values of some fields?
For example:
The "ACCOUNT" object has a "STATUS" property with the values paid/partially paid/cancelled and so on.
[{
"id":1,
"sum": 100,
"status": "paid",
"items": [
{
"id": 1,
"name": "Donut",
"price": 50,
"quantity ": 2
}
]
}]
An HTML form must be generated on the client to edit account data. The account status must be selected from the list of available values.
So far I see several options:
1) Describe all possible values in the API documentation. This will fix the list of available values on the client. Minus - when adding a new status, you need to change the client code.
2) Provide an API for getting a list of statuses (/v1/invoices/statuses, /v1/invoices/1/statuses). The client separately downloads account data and status data separately.
Do you know any API examples where this situation is somehow solved? Tell us about your experience.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question