Objective: To provide you with resources to obtain an API.
Difficulty: Advanced
Who is this for: Enterprise accounts
In this article:
- Overview
- How to retrieve an API token
- API key and sample queries
- How to retrieve a list of components
- How to retrieve a component by ID
- API Schema Document
Increase speed and accuracy by using Duro's API to access your data. Lower the likelihood of errors through automation and integrate more thoroughly to 3rd party systems, servers, and databases.
Overview
Duro provides an API to customers with an active PLM Enterprise account. By using a Duro-provided key to access Duro’s GraphQL API, users can query rich data surrounding their component and product libraries. In this document, you will find two sample queries: one to retrieve a list of components and another to retrieve a single component based on its ID. The components
query provides a long list of all components which can be sorted by name, date, mass, revision, category, etc. (subject to change). The componentsByIds
query can subsequently be used once the ID of the component is obtained to load further component details.
If you have any questions on Duro's GraphQL API, send an email to api@durolabs.co. For more information on how Duro utilizes webhooks in conjunction with APIs, please refer to our article on Webhooks.
How to retrieve an API token
To retrieve an API token in your Duro app, follow the directions below:
- Login into your Duro account.
- Click on your avatar and select Account Settings.
- In the Settings menu, select the Integrations tab.
- Click on the Get API Key button below the Integrations table.
- This will present the key. Highlight and copy the key.
Every token is uniquely generated per user and lasts for 90 days. An existing token may be used to generate a new token using the query:
{
apiToken {
token
}
}
API key and sample queries
Curl example with API key and query
Clients with dedicated hosting environments have a unique link for obtaining their API key and query:
- Base API URL: https://mfg.duro.app/graphql
- ITAR clients: https://app.govduro.us/graphql
curl -XPOST https://mfg.duro.app/graphql \ -H 'apiToken: <my_token>' \ -H 'Content-Type: application/json' \ --data '{ "query": "<GraphQL_query>" }'
Components query
{
components(libraryType: GENERAL) {
connection(
first: 1000
) {
totalCount
edges {
cursor
node {
id
name
created
lastModified
}
}
}
}
}
Component by ID query
{
componentsByIds(id: <some_id>) {
id
alias
name
mode
cpn {
id
prefix
counter
variant
displayValue
}
children {
itemNumber
quantity
assemblyRevision {
mass
alias
}
}
company {
id
name
users {
id
firstName
}
}
revisions {
id
name
subRevisions {
id
name
}
}
}
}
How to retrieve a list of components
To retrieve a list of components, follow the directions below:
- Open the API tool of your choice (such as Postman or Curl).
- Paste the key copied from Duro into the API token header. Ensure that any carriage returns are removed.
- In the body, create a
components
query (optional: use the sample query provided in the API key and sample queries section above). - Run the query.
The response structure is based on the GraphQL relay specification which includes a connection with an array of edges and nodes. The more fields requested, the more information will be returned. However, larger queries with more fields will potentially render slower results.
How to retrieve a component by ID
To procure individual component information, you can run component queries individually. To retrieve a component by ID, follow the directions below:
- Open the API tool of your choice (such as Postman or Curl).
- Paste the key copied from Duro into the API token header. Ensure that any carriage returns are removed.
- In the body, create a
componentsByIds
query (optional: use the sample query provided in the API key and sample queries section above). - Copy an ID from the list generated by the
components
query. - Paste the ID into the
componentsByIds
ids
argument and include any additional fields as needed. - Run the query.
This query will return a more detailed response with additional fields such as component fields, company ID, revisions, etc. For a full list of returned fields, see the latest schema documentation.
API schema and additional resources
You can find the full list of available Duro API queries and types in the Duro GraphQL API documentation.
If you have any questions on Duro's GraphQL API, send an email to api@durolabs.co.
By default the API uses the company library; however, if you would prefer to use a personal Sandbox library for testing, please refer to our article on API Testing in the Sandbox.
Comments
0 comments
Please sign in to leave a comment.