Synopsis

# Install tools
sudo apt-get install curl jq
wget http://blog.geeky.name/public/taiga.user_token.sh
chmod +x taiga.user_token.sh

# Get Token
./taiga.user_token.sh

# Get Project ID
curl -X GET \  
  -H "Content-Type: application/json" \  
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
https://api.taiga.io/api/v1/projects/by_slug?slug=${PROJECT_SLUG}

# Set color
curl -X PATCH \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
  -d \
'{
    "tags_colors": {
        "normal": "#0000ff",
        "important": "#fcaf3e",
        "high": "#ff0000"
    }
}' \
https://api.taiga.io/api/v1/projects/${PROJECT_ID}


What's Taiga?

Taiga.io is a cool OpenSource Project Management tool for Scrum / Agile Development.
I use it in my company, side projects, and also introduce it in my classes in university
It has Free Hosting service for public projects, and paid version for private project.

Tags

In my teams we use Tags to prioritize Tasks, High with color Red, normal with color Blue, etc.
But there's no place in it's UI for setting tag color, so have to set it manually via REST interface.
You can't set the color when adding Tags to the Tasks, it's generated by system automatically, so we'll guide you to change tags_colors to fit your needs here.
This guide use Ubuntu Linux, but it should be the same on other linux distro and Mac OSX.

Tools

Two tools you need:

  • curl
  • jq

You can install by using the following command:

$ sudo apt-get install curl jq

Steps

OK now here's what the process is.

Prepare Information

You have to be an Admin of the project you wanna modify.
You need two informations prepared before you can change color:

  • Login Token
  • Project ID

1. Getting your own Login Token / Credential

Use the script on their site or download it HERE.
Run it and follow it's steps:

$ chmod +x ./taiga.user_token.sh && ./taiga.user_token.sh

Then you'll get something like this:

Username or email: BlueTxxx@xxx.xxx
Password: xxxx
auth_token is XXXXXXXXX

Save the token for later use.
Let's call it ${AUTH_TOKEN}.

2. Get the Project ID

Use your project slug to find ID. Taiga use the word slug but you can treat it as the Name of your project.
When you open your project in browser, you can see something like https://tree.taiga.io/project/bluet-test-project where the "bluet-test-project" is the slug.
Let's call it ${PROJECT_SLUG}.

Now run the command in your Terminal.
Remember to replace ${AUTH_TOKEN} and ${PROJECT_SLUG} to your actual string.

$ curl -X GET \  
  -H "Content-Type: application/json" \  
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
https://api.taiga.io/api/v1/projects/by_slug?slug=${PROJECT_SLUG}

Find the Project ID "id" at the 1st level. Save it for later use.
You can also use THIS online JSON prettifier to help you find it more easier. Scroll up from the bottom (end of the file) so you can find it quicker.
Let's call it ${PROJECT_ID}.



Working on Tag Color

There are two things you need to keep in mind:

  • The Tag must be created and exist (already using on some Tasks). If not, next time when you (firstly) use this tag on tasks, will trigger the creating process and overwrite current settings.
  • If you remove the tag from all tasks, the tag itself and it's settings will be removed.
  • You can create a "Tag Color Holder" Task to ensure above cases won't happen.

1. Retrieve Current Settings

Run the command to check the data format and ensure everything's prepared.

$ curl -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
  https://api.taiga.io/api/v1/projects/${PROJECT_ID}/tags_colors

You'll see something like this:

{"normal": "#75507b", "important": "#fcaf3e", "high": "#4e9a06"}

As you can see, we have "high" and "normal" tags exist, but not the color I want.

2. Set the Color You Want

Be careful of the POST data structure. It's a little different from what we got in previous command.

$ curl -X PATCH \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
  -d \
'{
    "tags_colors": {
        "normal": "#0000ff",
        "important": "#fcaf3e",
        "high": "#ff0000"
    }
}' \
https://api.taiga.io/api/v1/projects/${PROJECT_ID}

The whole project data with new settings will show on the screen, but we don't care, if there's no error.
Retrieve your tags_colors settings again to check if they've been modified correctly.
The same command in previous section:

$ curl -X GET \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${AUTH_TOKEN}" \
  https://api.taiga.io/api/v1/projects/${PROJECT_ID}/tags_colors

Bingo! The result is:

{"normal": "#0000ff", "important": "#fcaf3e", "high": "#ff0000"}

Confirm and Enjoy

Now go to your https://tree.taiga.io/projects/${PROJECT_ID} in your browser and check task colors in your Sprint.

Ref

  • http://taigaio.github.io/taiga-doc/dist/api.html#_authentication
  • http://taigaio.github.io/taiga-doc/dist/api.html#projects-get-by-slug
  • https://groups.google.com/forum/#!topic/taigaio/gRoO-RVeKo8