09-30-2022 09:04 AM
We would like to access our ST data using API. Unfortunately this is something we are not entirely familiar with. Is there anyone out there using API to pull data into a data repository, create reports, etc? I am stuck on the actual set up. Is this something that can be done locally on a SQL server? Would we need to get a 3rd party involved or purchase a program to use for this? I may be asking the wrong questions considering this is one of those "you don't know what you don't know" situations but hopefully this gets my point across. Any information would be HUGELY appreciated. Documentation, screenshots, links, really anything that could help. I checked out the info provided by ST which is helpful but not quite what I need to get things to click for me. Thank you in advance!
Solved! Go to Solution.
10-01-2022 07:56 AM
pip install requests
{
"CLIENT_ID": "cid.hhmdjd1jk9nqwertyr5cl6t5u5r5",
"CLIENT_SECRET": "cs2.yjnblmqpfiuzjyqwerty5gc28a35qabzo1qsss2l3fll5st64tgrxjxz",
"APP_ID": "12abc346skeg",
"APP_KEY": "ak1.qey12fgjhnch03lsm",
"TENANT_ID": "1234567890",
}
import requests
# Fill in each of these variables and they will
CLIENT_ID = ""
CLIENT_SECRET = ""
APP_KEY = ""
TENANT_ID = ""
# --- GETTING YOUR AUTH TOKEN ----
url = "https://auth.servicetitan.io/connect/token"
payload = f"grant_type=client_credentials&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
token = response['access_token']
# --- GETTING DATA FROM THE ESTIMATES ENDPOINT ----
url = f"https://api.servicetitan.io/sales/v2/tenant/{TENANT_ID}/estimates"
querystring = {"pageSize":"100","active":"true","soldAfter":"2022-09-28T00:00:00Z","page":"1"}
payload = ""
headers = {
"Authorization": token # this is the token you request above,
"ST-App-Key": APP_KEY # one of the items you got from servicetitan above
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.json())
If you want to explore the ServiceTitan API with a more friendly interface I could recommend using a tool like Postman or Insomnia for testing your requests to make sure they're correct. They also generate sample code in your language of choice (its how I made the code above).
10-03-2022 10:03 AM
What exactly are you trying to create; can you describe an example end result? I know you say reports, but can you describe in greater detail one of the reports you'd like to create with API data?
If you aren't familiar with making API requests, coding in Python and/or JSON, then I would absolutely look to a 3rd party.
10-03-2022 09:30 AM
@PamDuffy-PCG is this something you can help with?
10-03-2022 07:19 AM
We have not started to use the API interface yet, other than Zapier. We have an in-house IT person who has some experience with API's and even he wanted to consult a third party before he started down that path. So I would suggest a 3rd party!
10-01-2022 07:56 AM
pip install requests
{
"CLIENT_ID": "cid.hhmdjd1jk9nqwertyr5cl6t5u5r5",
"CLIENT_SECRET": "cs2.yjnblmqpfiuzjyqwerty5gc28a35qabzo1qsss2l3fll5st64tgrxjxz",
"APP_ID": "12abc346skeg",
"APP_KEY": "ak1.qey12fgjhnch03lsm",
"TENANT_ID": "1234567890",
}
import requests
# Fill in each of these variables and they will
CLIENT_ID = ""
CLIENT_SECRET = ""
APP_KEY = ""
TENANT_ID = ""
# --- GETTING YOUR AUTH TOKEN ----
url = "https://auth.servicetitan.io/connect/token"
payload = f"grant_type=client_credentials&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
token = response['access_token']
# --- GETTING DATA FROM THE ESTIMATES ENDPOINT ----
url = f"https://api.servicetitan.io/sales/v2/tenant/{TENANT_ID}/estimates"
querystring = {"pageSize":"100","active":"true","soldAfter":"2022-09-28T00:00:00Z","page":"1"}
payload = ""
headers = {
"Authorization": token # this is the token you request above,
"ST-App-Key": APP_KEY # one of the items you got from servicetitan above
}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.json())
If you want to explore the ServiceTitan API with a more friendly interface I could recommend using a tool like Postman or Insomnia for testing your requests to make sure they're correct. They also generate sample code in your language of choice (its how I made the code above).
03-11-2024 06:27 PM
Hi Elliot,
I am working to achieve some functionality here for an app we are building. Would it be okay to compare some notes and ask a few questions? I used your servicepytan with success, and I am looking to integrate some webhooks using google Cloud function/run and other google apps where I am trying to call the ST API.
Happy to share what I have and maybe get some advice on how to go about making a few functions work. I connected with you on Linkedin. Cheers.
09-30-2022 03:39 PM - edited 09-30-2022 03:41 PM
After doing a bit of digging I found a page that may be helpful for you!
https://help.servicetitan.com/how-to/get-started-with-apidev-portal-v2
This page shows you how you can get started with our dev portal!
Looks like you will want to send an email to integrations@servicetitan.com to get assistance in creating a custom API! Hope this is helpful!