These examples for PowerBI use the free Power BI Desktop application.
TABLE OF CONTENTS
- Supply example: Retrieve the manufacturer name of a part by MPN
- Design Example: Access your project releases
- Design Example: Access component parameters in your library:
- DatRep Example: Accessing Company Reports
- Common Issues
Requirements:
Your bearer token. This can be found under Apps > Your Application Name > Authorization
Open Power BI desktop, and select Get data > Blank query
This should open a new Power Query Editor.
From here, right-click on your new Query and click Advanced Editor. Alternatively, select Advanced Editor from the ribbon toolbar above.
Copy and paste the code from the examples below in the Advanced Editor window.
Supply example: Retrieve the manufacturer name of a part by MPN
let vUrl = "https://api.nexar.com/graphql", vHeaders =[ #"Method"="GET", #"Content-Type"="application/json", #"Authorization"="Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjA5NzI5QTkyRDU0RDlERjIyRDQzMENBMjNDNkI4QjJFIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE3MDg1MTM4NzIsImV4cCI6MTcwODYwMDI3MiwiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS5uZXhhci5jb..." ], vContent=Text.ToBinary("{""query"":""query q2 { supSearch(q: \""500R14N220JV4T\"", limit: 3) { results { part { mpn manufacturer { name } } } } }""}"), Source = Web.Contents(vUrl, [Headers=vHeaders, Content=vContent]), #"JSON" = Json.Document(Source) in JSON
Make sure to insert your own bearer token after "Authorization"="Bearer ... <insert your bearer token>"
Make sure there are no syntax errors, then click Done.
From here, you should be able to see the data from the query.
Click through data Record > supSearch Record > results List > Record > part Record
You will see the MPN as in the query above.
You can then click on manufacturer Record to see the manufacturer name of this part.
Design Example: Access your project releases
let vUrl = "https://api.nexar.com/graphql", vHeaders =[ #"Method"="POST", #"Content-Type"="application/json", #"Authorization"="Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjA5NzI5QTkyRDU0RDlERjIyRDQzMENBMjNDNkI4QjJFIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE3MDg1MTM4NzIsImV4cCI6MTcwODYwMDI3MiwiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS5uZXhhci5jb20iLCJjbGllbnRfaWQiOiJ... ], vContent=Text.ToBinary("{""query"":""query getProjectIDs { desProjects(workspaceUrl: \""https://altium-inc-123.365.altium.com\"") { nodes { id name design { releases { nodes { description } } } } }}""}"), //vContent=Text.ToBinary("{""query"":""query q2 { supSearch(q: \""500R14N220JV4T\"", limit: 3) { results { part { mpn manufacturer { name } } } } }""}"), //vContent=Text.ToBinary("{""query"":""query { desWorkspaces { name url location { apiServiceUrl filesServiceUrl } }}""}"), Source = Web.Contents(vUrl, [Headers=vHeaders, Content=vContent]), #"JSON" = Json.Document(Source) in JSON
Make sure to remove "https://altium-inc-123.365.altium.com\" from the example above and insert your own workspace url
Here, you can click through data Record > desProjects Record > nodes List > List Record to find the information about that workspace.
Design Example: Access component parameters in your library:
let vUrl = "https://api.nexar.com/graphql", vHeaders =[ #"Method"="POST", #"Content-Type"="application/json", #"Authorization"="Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjA5NzI5QTkyRDU0RDlERjIyRDQzMENBMjNDNkI4QjJFIiwidHlwIjoiYXQrand0In0.eyJuYmYiOjE3MDg1MTM4NzIsImV4cCI6MTcwODYwMDI3MiwiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS5uZXhhci5jb20..." ], vContent=Text.ToBinary("{""query"":""query library { desLibrary(workspaceUrl: \""https://altium-inc-4548.365.altium.com\"") { components { nodes { id name details { parameters { type name value } } } } }}""}"), //vContent=Text.ToBinary("{""query"":""query getProjectIDs { desProjects(workspaceUrl: \""https://altium-inc-123.365.altium.com\"") { nodes { id name design { releases { nodes { description } } } } }}""}"), //vContent=Text.ToBinary("{""query"":""query { desWorkspaces { name url location { apiServiceUrl filesServiceUrl } }}""}"), Source = Web.Contents(vUrl, [Headers=vHeaders, Content=vContent]), #"JSON" = Json.Document(Source) in JSON
Make sure to remove "https://altium-inc-123.365.altium.com\" from the example above and insert your own workspace url
Here, you can click through data Record > desLibrary Record > components Record > nodes List > List Record to find the information about that component in your library.
DatRep Example: Accessing Company Reports
To get started with Reporting Data, look at our guide: Report Data Query: Introduction to DatRep. If you are interested in Octopart reporting, please contact our business team at: [email protected] or via our support ticketing here.
let vUrl = "https://api.nexar.com/graphql", vHeaders =[ #"Method"="POST", #"Content-Type"="application/json", #"Authorization"="Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjA5NzI5Q..." ], vContent=Text.ToBinary( "{""query"":""query GetReports { datRepReports( companyId: \""1234\"" ) { totalCount nodes { id fileType fileSize createdDate title ... on DatRepOctopartReport { companyId } } }}""}"), Source = Web.Contents(vUrl, [Headers=vHeaders, Content=vContent]), #"JSON" = Json.Document(Source) in JSON
Make sure to add your bearer token, and change the companyId from the example above and insert your own companyId.
Here, you can click through data Record >datRepReports Record > nodes List > List Record to find the information about your reports.
Common Issues
Please specify how to connect.
There may be a yellow popup that says:
Click, "Edit Credentials":
Ensure you are on Anonymous in the left hand panel, and the level to apply these settings to is "https://api.nexar.com".
Click "Connect".
If you see this error:
You may need to refresh your credentials.
Click "Cancel"
In the top ribbon, you will see a button "Data source settings" - click it.
Select "Global Permissions", then select "https://api.nexar.com", and "Clear Permissions"
Information is required about data privacy.
If you see this error, click "Continue", then select "Ignore Privacy Level checks for this file..." and "Save".
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article