api
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
api [2017/12/05 23:45] – flack | api [2019/09/25 17:28] – [Quote - Missing structures] flack | ||
---|---|---|---|
Line 229: | Line 229: | ||
Authentication is currently a token based authentication. | Authentication is currently a token based authentication. | ||
- | If you would like to access our protected API endpoints, please drop us an email at info@mcule.com and we can provide you with a token. | + | If you would like to access our protected API endpoints, please drop us an email at support@mcule.com and we can provide you with a token. |
Once you have a valid token you have to send it in the Authorization header: | Once you have a valid token you have to send it in the Authorization header: | ||
Line 236: | Line 236: | ||
</ | </ | ||
+ | Example: | ||
+ | < | ||
+ | Authorization: | ||
+ | </ | ||
+ | |||
+ | If you have a valid access token you can check it on the [[https:// | ||
====== Protected API endpoints ====== | ====== Protected API endpoints ====== | ||
Line 486: | Line 492: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ===== Compound suppliers public API ===== | ||
+ | |||
+ | You can get some very basic (public) information about our compound suppliers with this API. | ||
+ | |||
+ | == Endpoint: == | ||
+ | < | ||
+ | |||
+ | == Example API request: == | ||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | == Example request: === | ||
+ | < | ||
+ | GET / | ||
+ | Accept: */* | ||
+ | Accept-Encoding: | ||
+ | Authorization: | ||
+ | </ | ||
+ | |||
+ | == Example response: === | ||
+ | < | ||
+ | HTTP/1.1 200 OK | ||
+ | Allow: GET, HEAD, OPTIONS | ||
+ | Connection: keep-alive | ||
+ | Content-Encoding: | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | | ||
+ | ... | ||
+ | | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The detail API endpoint is also available on this endpoint: | ||
+ | < | ||
+ | |||
+ | It will return a similar response as the above one but for an individual compound supplier. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Compound catalogs public API ===== | ||
+ | |||
+ | You can get some very basic (public) information about our compound catalogs with this API. | ||
+ | |||
+ | == Endpoint: == | ||
+ | < | ||
+ | |||
+ | == Example API request: == | ||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | == Example request: === | ||
+ | < | ||
+ | GET / | ||
+ | Accept: */* | ||
+ | Accept-Encoding: | ||
+ | Authorization: | ||
+ | Connection: keep-alive | ||
+ | </ | ||
+ | |||
+ | == Example response: === | ||
+ | < | ||
+ | HTTP/1.1 200 OK | ||
+ | Allow: GET, HEAD, OPTIONS | ||
+ | Connection: keep-alive | ||
+ | Content-Encoding: | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | |||
+ | ... | ||
+ | | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | The detail API endpoint is also available on this endpoint: | ||
+ | < | ||
+ | |||
+ | It will return a similar response as the above one but for an individual compound catalog. | ||
+ | |||
+ | |||
+ | |||
+ | ===== Quote Request API ===== | ||
+ | |||
+ | == Endpoint: == | ||
+ | < | ||
+ | |||
+ | == Example API request: == | ||
+ | < | ||
+ | echo ' | ||
+ | </ | ||
+ | |||
+ | Mandatory fields: | ||
+ | * **mcule_ids**: | ||
+ | * **customer_first_name**: | ||
+ | * **customer_last_name**: | ||
+ | * **delivery_country**: | ||
+ | |||
+ | |||
+ | Optional fields: | ||
+ | * **amount**: Preferred amount per molecule (mg). (default: 1) | ||
+ | * **min_amount**: | ||
+ | * **target_volume**: | ||
+ | * **target_cc**: | ||
+ | * **customer_email**: | ||
+ | * **delivery_time**: | ||
+ | * **purity**: Required minimum purity (%). (default: null) | ||
+ | * **higher_amounts**: | ||
+ | * **item_filters**: | ||
+ | |||
+ | The **amount** or target concentration-volume pair (**target_volume** and **target_cc**) need to be specified. | ||
+ | |||
+ | **item_filters** example: | ||
+ | It has to be a data structure where keys are mcule IDs you specified in the **mcule_ids** field. If you specify a key that is not an item in the **mcule_ids** list you should get a validation error (400 Bad Request). | ||
+ | Currently only supplier filtering is supported. You can specify a supplier ID list in the **suppliers** field to restrict product selection of a given item to a list of suppliers. If the list contains only one supplier ID, you restrict the product selection to that particular supplier. To get the ID of a supplier you can use the [[api# | ||
+ | < | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Advanced optional fields: | ||
+ | * **keep_original_salt_form**: | ||
+ | * **keep_original_tautomer_form**: | ||
+ | * **keep_original_stereo_form**: | ||
+ | * **deliver_multiple_salt_forms**: | ||
+ | |||
+ | |||
+ | == Example request: === | ||
+ | < | ||
+ | POST / | ||
+ | Accept: application/ | ||
+ | Accept-Encoding: | ||
+ | Authorization: | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | ], | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | == Example response: === | ||
+ | < | ||
+ | HTTP/1.1 201 CREATED | ||
+ | Allow: GET, POST, HEAD, OPTIONS | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Quote Request Status API ===== | ||
+ | |||
+ | Since processing a quote request and generating suitable quotes can take some time it is an asynchronous process. You can query the status of a quote request by calling the detail API endpoint of the quote request. It is returned in the **api_url** field when you create the quote request. You can also use the **id** field to construct the url of the API call. You can check the **state** field of the response whether the async quote request processing is finished. | ||
+ | |||
+ | States: | ||
+ | * **10 / Pending**: The quote query is queued but the processing has not started yet. | ||
+ | * **20 / Running**: The processing of the quote query is in progress. | ||
+ | * **30 / Done**: The processing of the quote query is finished. For one quote request query we might generate multiple quotes (this is what we call a group) or it is also possible that we could not generate any quotes for a particular quote request. If there are quotes they will appear under the **group** field where the **quotes** field contains a list of the generated quotes and some basic info about them. You can get detailed data of a particular quote by calling the endpoint specified in the **api_url** field. | ||
+ | * **40 / Error**: An error happened during the processing of the quote query. | ||
+ | |||
+ | Following the above example where the ID of the quote request is //15029// we query the status of the quote request: | ||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | == Example request: === | ||
+ | |||
+ | < | ||
+ | GET / | ||
+ | Accept: */* | ||
+ | Accept-Encoding: | ||
+ | Authorization: | ||
+ | </ | ||
+ | |||
+ | == Example response: === | ||
+ | < | ||
+ | HTTP/1.1 200 OK | ||
+ | Allow: GET, HEAD, OPTIONS | ||
+ | Connection: keep-alive | ||
+ | Content-Encoding: | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Check for the **group** field. If it is not null, we could generate some quotes for your quote query. As you can see from the above result, we could generate 3 different quotes for the quote query. A "Best price" quote, a " | ||
+ | |||
+ | ===== Quote API ===== | ||
+ | |||
+ | In order to get the detailed data of an individual quote, you can call the detail API endpoint of a quote, for example for the quote with ID //15677//: | ||
+ | |||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | == Example request: === | ||
+ | < | ||
+ | GET / | ||
+ | Accept: */* | ||
+ | Accept-Encoding: | ||
+ | Authorization: | ||
+ | </ | ||
+ | |||
+ | == Example response: === | ||
+ | < | ||
+ | HTTP/1.1 200 OK | ||
+ | Allow: GET, HEAD, OPTIONS | ||
+ | Content-Encoding: | ||
+ | Content-Type: | ||
+ | |||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ], | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | == Fields: === | ||
+ | |||
+ | Where currency is not specified, it is always USD. | ||
+ | |||
+ | * **analytical_services_price**: | ||
+ | * **avg_product_price**: | ||
+ | * **catalog_data**: | ||
+ | * **products_count**: | ||
+ | * **products_price**: | ||
+ | * **effective_price_display**: | ||
+ | * **avg_effective_price**: | ||
+ | * **delivery_time**: | ||
+ | * **quote**: The ID of the quote this catalog level quote data belongs to. | ||
+ | * **coverage_percent**: | ||
+ | * **created**: | ||
+ | * **delivery_days**: | ||
+ | * **delivery_price**: | ||
+ | * **duplicate_count**: | ||
+ | * **extra_handling_price**: | ||
+ | * **group**: | ||
+ | * **id**: The ID of the Instant Quote. | ||
+ | * **is_expired**: | ||
+ | * **is_saved**: | ||
+ | * **items**: list of product level data | ||
+ | * **amount**: Quoted amount (mg) | ||
+ | * **effective_price_display**: | ||
+ | * **price**: effective price | ||
+ | * **product_mcule_id**: | ||
+ | * **product**: | ||
+ | * **product_compound_mcule_id**: | ||
+ | * **product_delivery_time**: | ||
+ | * **product_price**: | ||
+ | * **product_purity**: | ||
+ | * **structure_origin_mcule_id**: | ||
+ | * **quote**: The ID of the quote this product level quote data belongs to. | ||
+ | * **missing_mcule_ids**: | ||
+ | * **name**: The name of the quote. Quotes created via the API don't have names. | ||
+ | * **order_data**: | ||
+ | * **payment_due_days**: | ||
+ | * **price**: Total price of quote (USD) | ||
+ | * **price_items**: | ||
+ | * **product_discount_price**: | ||
+ | * **products_price**: | ||
+ | * **query**: The quote query fields | ||
+ | * **reference_id_full**: | ||
+ | * **reformatting_price**: | ||
+ | * **shipping_price**: | ||
+ | * **site_url**: | ||
+ | * **special_formatting_price**: | ||
+ | * **state**: State code of the quote. | ||
+ | * **state_display**: | ||
+ | * **supplier_data**: | ||
+ | * **delivery_price**: | ||
+ | * **delivery_time**: | ||
+ | * **effective_price**: | ||
+ | * **avg_effective_price**: | ||
+ | * **products_count**: | ||
+ | * **products_price**: | ||
+ | * **quote**: The ID of the quote this supplier quote data belongs to. | ||
+ | * **reformatting_price**: | ||
+ | * **supplier**: | ||
+ | * **suppliers_count**: | ||
+ | * **total_cost**: | ||
+ | * **total_cost_without_discount**: | ||
+ | * **total_discount_price**: | ||
+ | * **type**: Type code of the quote. | ||
+ | * **type_display**: | ||
+ | * **updated**: | ||
+ | * **valid_until**: | ||
+ | | ||
+ | ==== Quote - Missing structures ==== | ||
+ | |||
+ | You can get the missing structures along with the reason of their exclusion. | ||
+ | |||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Download quote as PDF ==== | ||
+ | |||
+ | You can download a quote as a PDF file. Please note that the PDF file generation can take some time, the more item it contains the more time it will take to generate the file. | ||
+ | |||
+ | The HTTP response contains a // | ||
+ | |||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | ==== Download quote as Excel (.xlsx) file ==== | ||
+ | |||
+ | You can download a quote as an Excel file. Please note that the file generation can take some time, the more item it contains the more time it will take to generate the file. | ||
+ | |||
+ | The HTTP response contains a // | ||
+ | |||
+ | < | ||
+ | http https:// | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ====== Code examples (Python) ====== | ||
+ | |||
+ | We created a public Git repository that contains Python code examples on how to use the Mcule API. These examples supplement the above API documentation and might give you a better understanding on how you can utilize those API endpoints currently. | ||
+ | |||
+ | The repository is available here: | ||
+ | [[https:// | ||
+ | |||
+ | We'll probably extend this repository with new examples later. | ||
+ |
api.txt · Last modified: 2024/05/10 08:12 by bkovats