Giter Club home page Giter Club logo

togglwrapper's Introduction

Toggl Wrapper

Python library to easily interface with Toggl's API.

Implements all of Toggl's main API. The Reports API is not yet supported (coming soon).

Works in Python 2.7+ and Python 3+, and uses requests.

Toggl

Toggl is free time tracking software.

Features

  • Handles authentication for you: only need to provide your API token once
  • The most complete Python wrapper: implements all of v8 API.
  • Convenient install from PyPI
  • Easy to make requests to custom URLs
  • Python2 and Python3 compatible

Install

$ pip install togglwrapper

Quickstart

>>> from togglwrapper import Toggl
>>> toggl = Toggl('your_api_token')
>>> toggl.User.get()
{u'data': {
    u'achievements_enabled': True,
    u'api_token': u'your_api_token',
    u'email': u'[email protected]',
    u'fullname': u'Your Name',
    ...
    }
}
>>> toggl.Clients.get()
[{
    u'at': u'2015-07-02T14:27:59+00:00',
    u'id': 12031893,
    u'name': u'Client Name',
    u'wid': 3928
}]
>>> toggl.Workspaces.get()
[{
    u'admin': True,
    u'api_token': u'your_api_token',
    u'id': 1234,
    u'name': u"Your workspace",
    ...
}]
>>> toggl.Clients.create({"client":{"name":"Very Big Company", "wid": 1234}})
{u'data': {u'id': 294021, u'name': u'Very Big Company', u'wid': 1234}}

Custom Request

Let's pretend that a new endpoint is released, for a new Toggl object: Addresses. This hypothetical endpoint is located at https://www.toggl.com/api/v8/addresses. We can GET all addresses, GET a specific address by ID, or POST to create a new address.

We can use the methods on the Toggl client, so we don't have to wait for a new version of togglwrapper that supports the new endpoint:

>>> from togglwrapper import Toggl
>>> toggl = Toggl('your_api_token')
>>> toggl.get('/addresses')
...
>>> toggl.get('/addresses/{address_id}')
...
>>> toggl.post('/addresses', data={"address": {"name": "Billing Address 1", "address": "123 Main St."}})
...

toggl.put and toggl.delete are also available.

Documentation

Find the full documentation here: http://togglwrapper.readthedocs.org/en/latest/

API Endpoints Documentation

For full details on what fields are required, and what endpoints are available, see the Toggl API docs

Running tests locally

Using virtualenv + virtualenvwrapper to keep the environment isolated:

  1. Create a testing virtualenv
  2. Install the test requirements
  3. python tests.py

Sample command line output:

$ mkvirtualenv twtests  # if creating the virtualenv for the first time
Running virtualenv [...]
(twtest) $ pip install -r test_requirements.txt
Collecting [...]
(twtest) $ python tests.py
.......................................................
----------------------------------------------------------------------
Ran 55 tests in 0.414s

OK
(twtest) $ deactivate
$

togglwrapper's People

Contributors

aarose avatar charlesthomas avatar dependabot[bot] avatar glyph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

togglwrapper's Issues

Change API URL to api.track.toggl.com because otherwise the wrapper will stop working after June 30th, 2021

Toggl is dropping support for API calls to www.toggl.com after June 30th:

Hi there,

We are reaching out because we detected your Toggl Track API usage coming to the www.toggl.com(or toggl.com) domain.

If you (or your company) have developed a custom integration, we want to remind you that the usage of www.toggl.com (or toggl.com) domains for the API will be dropped after 'June 30th 2021'.

We encourage you to perform the switch to api.track.toggl.com as soon as possible in order to prevent disruption. Please check the official API Documentation for any extra info.

The API URL is built into the extension so that a new release should be made. There is already a related PR #27

Since there are only a little less than two weeks to go, I would greatly appreciate if the PR could be approved and merged and a new release could be made.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.