How to use TMetric REST API

This article provides all the necessary information about using TMetric REST API, which allows users to access core TMetric data and learn the main capabilities of the app. 

As a developer, you can use all the available APIs to build your custom solution and extend the app functionality depending on your needs. For example, you can create your own integration between TMetric and the workflow management system you use at work.

TMetric API

The TMetric APIs are designed based on the REST principles. API requests are sent over an HTTPS connection and responses are received in JSON format. Requests sent over HTTP are redirected to HTTPS. 

You can make API requests using the following HTTPS methods:

  • GET
  • POST
  • DELETE
  • PUT

API token

To interact with TMetric APIs, you need an API token since we use the Bearer Authentication to secure the API calls. There's no API for getting the token, so you can generate it manually from your profile page

To get a TMetric API token

  1. Click your name in the left bottom corner.
  2. Select My Profile in the drop-down list.  
  3. On the My Profile page, click the Get new API token link.
  4. Copy the newly-created token and use it to make API requests.  

Note: An API token will be valid for 1 year. If you generate a new token, the previous one becomes invalid. 

Authorize Requests

To make requests to APIs, TMetric requires user authentication. For this, you should send your API token in the Authorization header of the request. Otherwise, you will get a 401 Unauthorized response. 

Sample API Request

Let's look at a simple example to clearly illustrate how to work with TMetric APIs. We will test the API calls with Visual Studio Code and the REST Client extension. Alternatively, you can use Postman for this purpose. 

In the following example, we will see how to retrieve all the time entries for a specific day. 

1. Open Visual Studio Code and install the REST Client extension. 

2. Find the corresponding reference in the APIs list.

3. Copy the API URL.

4. In VS Code, open a new file and paste the copied URL. 

5. Add the base TMetric URL - https://app.tmetric.com/ in front of the API one.

6. Replace {accountId} and {userProfileId} with your workspace ID and user ID.

Note: The easiest way to find your workspace ID and user ID is to generate a Team Summary report and copy these values from the browser address bar.  

7. Add your API token in the Authorization header as follows:

Authorization: Bearer <token> 

Note: If you use Postman, open the Authorization tab, enter your API key value in the Token field.

8. Save the file with an .http or .rest extension. 

9. Click the Send Request link above the API that appears once you save the file. 

10. On the right side of the window, you will see a response.

 

Didn’t find what you were looking for?

If you didn't find what you were looking for, you can make a support request or email us to support@tmetric.com. We'll be glad to help you personally.

Contact Us