Guides
GuidesLog In
Guides

API Explorer

Query, explore and export your DataNinja data from the new API page

The API Explorer answers the question "what's in my DataNinja data, and how do I get it out?" Use it to write DataNinja Query Language (DQL) queries, look up every object's fields and relationships, manage custom fields, export records to Excel, and create an API token for your own tools, such as a Power BI report or a NetSuite script.

📘

Beta Feature

The API Explorer is the redesigned API page and is currently in beta. To turn it on for your company, open a chat with our Support team. While it's off, you'll see the classic API page described in Utilizing DQL and the DataNinja API.


Open the API Explorer

Click on the gear icon, go to "All Lists", then click on the "API" result. The page has three tabs:

TabWhat It's For
QueryWrite and run DQL with suggestions and live error checking, view the results as a table or JSON, and export them
ObjectsBrowse every object's fields, relationships and picklist values, manage custom fields, and export records
LearnWork through a DQL guide with examples you can run, and create an API token for your integrations

The API Explorer isn't only for administrators: anyone who can sign in to DataNinja can use it. It runs with your own roles and permissions, so it never shows data you couldn't see elsewhere in DataNinja. If you query an object or field you don't have access to, you'll see "Access denied to object".

Bookmarks to the classic API page still work and open the matching tab.

The Query tab with a query and its results

Write and Run a Query

On the "Query" tab, type your query in the editor, then click "Run" or press Ctrl+Enter (Cmd+Enter on Mac). For example:

SELECT Id, Name FROM Part LIMIT 10

Suggestions and Error Checking

Suggestions open on their own after FROM, in the select list and in WHERE, and any time you press Ctrl+Space. They include objects, fields, relationships, collections, functions, operators, picklist values and date words such as TODAY, NOW, YESTERDAY and TOMORROW. Your own custom fields are included too.

As you type, an object or field name that doesn't exist is underlined. Hover over it to see what's wrong, such as "Foo is not a property of Part." If a query fails when you run it, the error appears under the editor, often with a suggestion such as "Did you mean Part?"

Field suggestions and an underlined unknown field in the Query tab editor

Keyboard Shortcuts

KeysAction
Ctrl+Enter (Cmd+Enter)Run the query
Ctrl+Alt+FFormat the query, one clause per line
Ctrl+SpaceOpen suggestions
↑ / ↓, then Enter or TabChoose and accept a suggestion
EscClose suggestions
Tab / Shift+TabIndent or outdent the selected lines
Alt+NOpen a new query tab

Select Every Field

SELECT * is a shortcut for every field on the object itself, including reference IDs. A badge shows how many fields it stands for, and double-clicking the * writes them all out in the editor.

It doesn't bring back related records or collections, so name those yourself, such as Customer.Name or a child query (see Bring Back Child Rows). On some objects, selecting every field returns "Internal Server Error". If that happens, select only the fields you need.

Query Tabs

Each query is its own tab, so you can keep several going at once. Click "New query" or press Alt+N to open another. Your query tabs and recent queries are saved in your browser for 24 hours.


Read and Export Results

The results header shows how many rows came back and how long the query took, such as "23 rows returned · 23 milliseconds". If more records matched than could be returned, it adds the total, such as "of 4,512 matches".

  • Table view shows 25, 50 or 100 rows per page, with a search box and a column chooser.
  • JSON view shows the rows exactly as the API returns them, which is useful when you're building an integration.

A count query such as SELECT COUNT() FROM Part shows a single number instead of rows.

Bring Back Child Rows

A child query (a select inside the select) returns each record together with its related records, such as each sales order with its lines:

SELECT OrderNumber, (SELECT LineNumber FROM Lines) AS Lines
FROM SalesOrder
LIMIT 25

Each row shows how many child rows came back. Open the count to see them as a table inside the row. Use the "Objects" tab to find the collection names you can use for an object.

Query results with a sales order's lines opened as a sub-table

Copy and Export

  • "Copy" copies every returned row: tab-separated text in Table view, or JSON in JSON view.
  • "Copy Query" copies your query with any * written out as field names, ready to paste into another tool.
  • "Export" downloads the results as an Excel workbook named "DQL Query Results" with the date and time, or as a .json file from JSON view. Numbers and true/false values stay typed in the workbook, so it's ready for sorting, filtering or a pivot table.

Explore Objects

The "Objects" tab describes everything you can query. The list on the left switches between:

  • All – every object
  • Recent – the 10 objects you've opened most in the last 7 days
  • Custom – objects that have custom fields, with a count of each

Type in "Filter objects..." to search by display name, API name or object code, then click on an object to open its "Properties". Each field shows its name, its type and details such as Required, Not queryable or Length. Use the column chooser to add columns such as API Name, Relationship, Required, Queryable and Updatable.

The Objects tab with the Sales Order object open on Properties

References and Collections

A reference points to one related record, such as a sales order's customer. A collection holds many related records, such as a sales order's lines. Open either one to see the related object's fields right under it, as many levels deep as you need.

Use a reference name with dot notation in a query (Customer.Name), and a collection name in a child query ((SELECT LineNumber FROM Lines) AS Lines).

📘

Don't See the Expand Arrows?

When the window is narrower than about 900 pixels, the property list switches to cards, which can't be expanded. Widen the window or collapse the side menu.

Sample Query and Export

Under the properties, a sample query (SELECT * FROM <Object> LIMIT 5) runs right there, so you can see real values before you write your own query.

"Export" on the properties table downloads that object's records as an Excel workbook, using the fields that match your current search and filters. Exports from the "Objects" tab have no row limit, so use them when you need more records than a query can return.


Manage Custom Fields

You can add, edit and delete Custom Fields from the "Objects" tab. Open an object and choose "Custom Fields", or choose "All custom fields" in the "Custom" list.

  1. Click "Add Custom Field".
  2. In the aside, enter the display name and API name (the __cf ending is added for you), choose whether it's required, and pick a type. For a picklist, add its options.
  3. Save. The field is listed right away, and you can query it immediately.

To change or remove a field, open the ⋯ menu on its row and choose "Edit" or "Delete". "Edit" opens the same aside with the field filled in. "Delete" asks you to confirm first.

"Export" on a custom field table downloads the records behind the listed fields: one workbook for one object, or a ZIP file of workbooks for several objects.

The Add Custom Field aside on the Part object
❗️

Deleting a Custom Field

Deleting a custom field removes the field itself, but the values already saved stay in the database, and the field still counts toward the object's limit of 200 custom fields. Only delete a field when you're sure you won't need it.

If you don't see "Add Custom Field", "Edit" or "Delete", custom field management is turned off for your company, often because custom fields are managed in your financial system instead. The page will say "Ask an administrator to turn on Can Manage Custom Fields to add one." Open a chat with our Support team if you need it turned on.


Learn DQL

The "Learn" tab teaches DQL in nine topics. Every example is a working editor: run it against your own data, change it, or copy it into the "Query" tab. Use the search box to find every example that uses a word.

TopicCovers
First querySELECT, aliases, SELECT *, COUNT(), LIMIT and OFFSET
FilteringComparisons, AND/OR, null values, LIKE, IN, CONTAINSANY and CONTAINSALL
DatesDate words such as TODAY, and offsets from them
RelationshipsDotted paths, CAST, semi-joins and many-to-many relationships
CollectionsChild queries, Exists/All/None/Count, UNION and limits
SummariesGROUP BY, HAVING, totals and DISTINCT
FunctionsCOALESCE, CONCAT, aggregates and geographic distance
TroubleshootingCommon errors and what they mean
API setupCalling DQL from your own tools, and creating an API token
The Learn tab with the First query topic open

Connect an Integration With an API Token

Other tools, such as Power BI or a script, use an API token to run DQL queries against your DataNinja data. Go to the "Learn" tab and open "API setup".

  • If you don't have a token yet, you'll see "You don't have an API token yet." Click "Create Token". The new token is named "API Explorer" and is shown once, with its expiry date and a copy button, so copy it right away.
  • If you already have a token, click "Go to API Tokens" to open the "API Tokens" tab on your user profile, where you can create more tokens or revoke them.
The API setup topic in the Learn tab with the Create Token button

Your tool sends a GET request to /api/dql/query, with your query in the dql parameter and the token in the ApiToken header. "API setup" shows the full request format and how to read the response. You can paste a query from the "Query" tab with "Copy Query".

GET /api/dql/query?dql=SELECT Id, Name FROM Part LIMIT 10
ApiToken: <your token>

Things to know about tokens:

  • A token acts with your own roles and permissions.
  • Each token expires one year after it's created.
  • You can have up to 10 active tokens, each with a unique name.
  • Users with the Contractor role can't create tokens.
  • Disabling or deleting a user, or moving them to the Contractor role, revokes their tokens.
🚧

Treat Tokens Like Passwords

Anyone with your token can read your DataNinja data with your permissions. Don't share it, and revoke it from the "API Tokens" tab on your profile when an integration is retired.


Limits

RuleLimit
Rows returned by a queryUp to 3,000. A LIMIT above that returns an error. Administrators have no maximum.
Child query rows100 by default and up to 250, with up to 5 child queries per query
Collection expressions per query12
Relationship depth in a dotted path6
Query timeout30 seconds
Exports from the Objects tabNo row limit
Custom fields per object200, with unique names on each object

To work with more rows than a query returns, page through them with LIMIT and OFFSET, or export the records from the "Objects" tab.


Troubleshooting

IssuePossible CauseSuggested Action
The classic API page shows instead of the new oneThe API Explorer isn't turned on for your company, or it didn't loadReload the page. If it still shows the classic page, open a chat with our Support team
"A LIMIT must be between 1 and 3000."The LIMIT is 0 or above the maximumUse a smaller LIMIT, page with OFFSET, or export from the "Objects" tab
"Did you mean Part?" under the editorAn object or field name is misspelledAccept the suggestion, or pick the name from the suggestions list
"SELECT * needs a FROM object so the fields can be expanded."The query uses SELECT * without a FROM objectAdd the FROM clause
"Internal Server Error" when selecting every fieldA field on that object can't be selected directlySelect only the fields you need
"Access denied to object"You (or the token's user) can't read that object or fieldAsk your administrator to review your Permissions
"Too many requests, try again later."The query took too long while the server was busyTry again, and narrow the query with WHERE and LIMIT
No expand arrows on references and collectionsThe window is too narrow, so properties show as cardsWiden the window or collapse the side menu
No "Add Custom Field", "Edit" or "Delete"Custom field management is turned off for your companyOpen a chat with our Support team
"You already have the maximum of 10 active API tokens. Revoke one before creating another."You have 10 active tokensRevoke a token you no longer use on the "API Tokens" tab of your profile
An integration gets "401 Unauthorized"The ApiToken header is missing, or the token was revoked or has expiredCreate a new token and update the integration
🚧

Current Limitations

The API Explorer doesn't show when a token was last used. The classic page's option to copy fields into the Query Window isn't carried over; use each object's sample query instead.