Using the AllSpice API
    • PDF

    Using the AllSpice API

    • PDF

    Article Summary

    AllSpice has a wonderful REST API. It's supported by the fantastic swagger api documentation system, so it's clean, easy to understand, and best of all, you can run and test the API commands in a web interface.

    Using our API you will be able to create, read, edit, and delete (CRUD) the following programattically:

    • Organizations
    • Teams
    • Users
    • Permissions
    • Repos
    • Branches
    • Commits
    • Tags
    • Releases
    • Issues
    • Pull Requests (PR) (aka design reviews)

    The API documentation has a great menu to help you focus on the specific commands you need.
    Screen Shot 2023-01-30 at 5.26.00 PM.png

    Authentication

    If you'd like to test the commands, you need to authorize/authenticate to securely talk to the website.

    Click on the "Authorize" button
    api-authorize-01.png

    Screen Shot 2023-01-30 at 5.34.52 PM.png

    You may also wish to use an access token. Learn how to generate an access token for AllSpice.

    Screen Shot 2023-01-30 at 5.58.33 PM.png

    Screen Shot 2023-01-30 at 5.26.00 PM.png

    Using the web interface

    Navigate to the api command you want to try out.

    You can always find the api documentation in the lower right corner of AllSpice Hub.
    api-link-01.png

    Here is a really simple api to prove you're logged in:
    https://hub.allspice.io/api/swagger#/user/userGetCurrent

    To use any of the apis, you'll have to click on the "Try it out" button. Once you have done that, you will see an Execute button.
    api-get-user-hires.gif

    Before you execute the command, you will see documentation on what the response will be. Here we see an HTTP 200 (OK success) code and a JSON formatted response message. The data is organized in a dictionary data structure with keys on the left and values on the right. For example, using a json browser with the key "id" will return the value stored in "id".
    Screen Shot 2023-01-30 at 6.19.01 PM.png

    Click the Execute button to see the result
    api-user-get-execute.gif

    If you are logged in and authenticated, you should get a response that is similar, yet personal to the logged in user / access token.

    {
      "id": 314,
      "login": "AllSpiceUser",
      "full_name": "",
      "email": "allspiceuser@allspice.io",
      "avatar_url": "https://hub.allspice.io/avatars/dc9739eb3ca8c65524790565d59d1c0a",
      "language": "en-US",
      "is_admin": false,
      "last_login": "2023-01-24T20:12:21Z",
      "created": "2022-08-13T19:02:08Z",
      "restricted": false,
      "active": true,
      "prohibit_login": false,
      "location": "",
      "website": "",
      "description": "",
      "visibility": "public",
      "followers_count": 0,
      "following_count": 0,
      "starred_repos_count": 0,
      "username": "AllSpiceUser"
    }
    

    We recommend taking the time to familiarize yourself and browse the commands

    Using the API

    There are many different ways to consume a REST API. Our Continuous Improvement (CI) is still in-development, but when we roll it out, it will be the most convenient way of running automation on your projects. In the meantime, prototyping and running scripts on your desktop will allow you to get a head start at looking at and manipulating the data.

    Many electrical engineers use python, so our example will highlight how to get started running python scripts to talk to the api.

    We recommend py-gitea as the most robust wrapper. It doesn't support everything however, so you may have to extend it.

    We have a python project that uses a modified version of the py-gitea module that can add user groups to teams with specific permissions. It is a work-in-progress.

    We are in the middle of creating a more accessible "hello world" application that uses Langenfeld's application and will update this article and our original python project.


    Was this article helpful?