Procedure to use TeamGant's WEB API (using python)

What is Team Gant

What to introduce this time

What can i do?

https://support.teamgantt.com/article/132-teamgantt-api

How to get started

  1. First, create an account for TeamGant. (Free version is also available)
  2. Make a project and make a process
  3. Issue __Bearer Token __
  4. Get __User Token __ and __API Key __
  5. Test the command alone on the API reference page
  6. Code in Python.

How to issue bearer tokens

  1. Go to TeamGant's App Tokens page.
  2. Enter an appropriate name in New App Name and press Save.
  3. A token (long character string) will be returned at Token, so copy it.

image.png

Issuing user tokens and API keys

image.png

image.png

If successful, Response will be in the 200s. If it is in the 400s, it is an error, so please review the settings.

image.png

The strings api_key and user_token are returned in Response Body, so make a note of them.

Practice on the API reference page

You can test your API on the API Reference page. Using the API GetList for tasks as an example, I will explain the procedure for getting the task list for your day.

Command selection

Select TaskTasks from the heading on the left and press Get List. The window on the right is ready to try the __ / tasks? Today__ command.

Next, add __bearer token, user token, API key __ to the URL header.

Press Headers and then Add new header to enter the item name and value.

image.png

item 入力するitem名 Description of the value to enter
Bearer token TG-Authorization 取得したBearer tokenの先頭に"Bearer "Add
API key TG-Api-Key Create Sessionで取得したAPI key
User token TG-User-Token Create Sessionで取得したUser token

The screen like ↓ is displayed when the above three are set as Header. If you press Call Resource and Response 200 series is returned, it is OK.

image.png

With the above procedure, you can try the API in the API document on your browser.

__ API headers can be pinned! __ You can pin it by moving the mouse cursor to the right side of the input box. If you pin it, you don't have to enter the header every time you change the API command, which is easy.

image.png

Example using Python

The TeamGant API documentation also has a Python example. Here's an example I've tried.


# -*- coding: utf-8 -*-
import urllib.request
import codecs
import json
########################################################################
# TeamGant
########################################################################
class TeamGant():
    '''
constructor
    '''
    def __init__(self):
        self.APIheader={'TG-Authorization':'Bearer <Own bearer token>'
                       ,'TG-Api-Key'      :'<Own API key>'
                       ,'TG-User-Token'   :'<Own user token>'
                       }
        self.UrlBase = 'https://api.teamgantt.com/v1/'
    '''
Make a request to TeamGant
Argument ApiCmd: API command(Mandatory)
Argument iSaveName: File name specified when you want to write the result to a json file Body
    '''
    def _gatTGjson(self, ApiCmd="",iSaveName=""):
        __request = urllib.request.Request(self.UrlBase + ApiCmd, headers=self.APIheader)
        __response = urllib.request.urlopen(__request)
        __json = __response.read().decode("utf-8")
        if not len(iSaveName) == 0:
            print(__json, file=codecs.open('./' + iSaveName + '.json' , mode='w')) #Export
        return __json
    '''
Get today's task
    '''
    def GetTodayTask(self):
        cmd='tasks?today'       #Today's task
        return self._gatTGjson(cmd, 'TaskToday')

########################################################################
#Main function
########################################################################
if __name__ == '__main__':
    tg = TeamGant()             #Create a TeamGant class
    js = tg.GetTodayTask()      #Execute the method to get today's task and receive json
    json_dict = json.loads(js)  #Make the received json a dictionary type

Recommended Posts

Procedure to use TeamGant's WEB API (using python)
How to use OpenPose's Python API
[Python] How to use Typetalk API
[September 2020 version] Explains the procedure to use Gmail API with Python
[BigQuery] How to use BigQuery API for Python -Table creation-
(Python) Try to develop a web application using Django
Push notifications from Python to Android using Google's API
Speech transcription procedure using Python and Google Cloud Speech API
Use Trello API with python
python3: How to use bottle (2)
EXE Web API by Python
Use Twitter API with Python
[Python] How to use list 1
Post to Twitter using Python
How to use Python argparse
Start to Selenium using python
Web API with Python + Falcon
Python: How to use pydub
[Python] How to use checkio
Web scraping using Selenium (Python)
Use configparser when using API
Use subsonic API with python3
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
Use e-Stat API from Python
How to use Python bytes
Easy to use Nifty Cloud API with botocore and python
How to use machine learning for work? 03_Python coding procedure
Tweet Now Playing to Twitter using the Spotify API. [Python]
Output product information to csv using Rakuten product search API [Python]
Python: How to use async with
Proxy measures when using WEB API
Data acquisition using python googlemap api
[Python] How to use Pandas Series
[Python3] Google translate google translate without using api
How to use Requests (Python Library)
How to use SQLite in Python
Try using Pleasant's API (python / FastAPI)
[Introduction to Python] Let's use pandas
Use kabu Station® API from Python
Hit the web API in Python
[Python] How to use list 3 Added
How to use Mysql in python
Use the Flickr API from Python
How to use ChemSpider in Python
How to use FTP with Python
Python: How to use pydub (playback)
How to use PubChem in Python
Try using Python argparse's action API
Easy to use Jupyter notebook (Python3.5)
Beginners use Python for web scraping (1)
How to use bing search api
[Introduction to Python] Let's use pandas
How to use python zip function
Run Ansible from Python using API
Beginners use Python for web scraping (4) ―― 1
[Introduction to Python] Let's use pandas
Use Google Analytics API from Python