ā† Threads

API feedback round 1

T
tyro 11 months ago

Ok, so the very first version of the API is now live at https://api.taskml.com. In short, it lets you manage simple tasks and projects within workspaces.

Overview

The main items are workspaces (where your stuff lives), projects, and tasks. Note that everything must have a valid parent. i.e. All projects belong to a workspace, and all tasks belong to a project.

workspace
  project
    task

Users also exist, and must be added to a workspace to be able to edit any project/task within that workspace (more info below).

Authorization

All requests (except ones to create new users) must be made with an Authentication header. i.e.

curl -X "GET" "https://api.taskml.com/tasks" -H "Authorization: Bearer YOUR_API_KEY_HERE" -H "Content-Type: application/json"

Making requests

Endpoints are as follows:

/workspaces
/projects
/tasks

This is a regular RESTful API. i.e.

POST /tasks       // Creates a task
GET /tasks         // Lists tasks
GET /tasks/:id     // Get a single task
PUT /tasks/:id     // Update an existing task 
DELETE /tasks/:id  // Deletes a task

Hereā€™s an example request:

curl --location 'https://api.taskml.com/projects' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
        "description": "Build a basic version of the API for early feedback and testing.",
        "name": "MVP",
        "status": "in progress",
        "workspace_id": 1
}'

You can use query params to filter list results by any property of the type youā€™re querying: e.g.

GET /tasks/:id?status=done

Data types

// User
{
    "email" => "elon@tesla.com",
    "name" => "Elon Musk",
}

// Workspace
{
    "name" => "Tesla",
    "description" => "For all Tesla projects and tasks.",
}

// Project
{
    "name" => "Model 3 refresh",
    "description" => "Updating the model 3 to modernize design and streamline manufacturing process.",
    "status" => "in progress",
    "workspace_id" => 1
}

// Task
{
    "name" => "Update design",
    "description" => "Update model 3 design using latest design cues from Model S Plaid.",
    "status" => "in progress",
    "project_id" => 1
}

Task and project statuses must be set to one of the following: ā€œtodoā€, ā€œin progressā€, ā€œcompleteā€, ā€œpausedā€, ā€œcanceledā€.

Getting started

  1. Create a user - POST https://api.taskml.com/users (no authorization header required for this)
  2. Create a workspace (using the access key returned in stage 1)
  3. Create a project (using the returned workspace id)
  4. Create tasks (using the returned project id)

Bonus

You can also invite other users to your workspace, and assign users to tasks/projects by POSTING to /workspace_users, /project_users and /task_users, which have the following data types:

// Workspace user
{
    "workspace_id" => 1,
    "user_id" => 1,
}

// Project user
{
    "project_id" => 1,
    "user_id" => 1,
}

// Task user
{
    "task_id" => 1,
    "user_id" => 1,
}

Hope that helps! If you have any questions, please let me know. šŸ™‚

T
tyro 11 months ago

Update. Iā€™ve expanded the info a bit to clarify what data you should send. Hereā€™s an example request:

curl --location 'https://api.taskml.com/projects' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "project": {
        "description": "Build a basic version of the API for early feedback and testing.",
        "name": "MVP",
        "status": "in progress",
        "workspace_id": 1
    }
}'

All data fields are required for all requests, except for ā€œdescriptionā€ fields.

T
tyro 11 months ago

Update, Iā€™ve removed the need to wrap your params when creating items.

Before:

curl --location 'https://api.taskml.com/projects' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "project": {
        "description": "Build a basic version of the API for early feedback and testing.",
        "name": "MVP",
        "status": "in progress",
        "workspace_id": 1
    }
}'

Now:

curl --location 'https://api.taskml.com/projects' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
    "description": "Build a basic version of the API for early feedback and testing.",
    "name": "MVP",
    "status": "in progress",
    "workspace_id": 1
}'

This is true when creating all resources (workspaces, projects, tasks, users etc).

D
dorianmariefr 11 months ago

canā€™t try it this week but will try next week

šŸ‘ 1
tyro reacted with :thumbs_up
T
tyro 11 months ago

Ok, so slight update. šŸ˜…

Based on feedback, Iā€™ve decided to remove workspaces as theyā€™re not that useful for personal tasks/projects.

So the new hierarchy is projects -> tasks. And getting started now looks like:

1. Create a user

POST https://api.taskml.com/users

with:

{
    "name": "Elon Musk",
    "email": "elon@tesla.com"
}

2. Create a project (using the access key returned in stage 1)

POST https://api.taskml.com/projects

Using Authorization header, and JSON data like:

{
    "name": "Model 3 refresh",
    "description": "Updating the model 3 to modernize design and streamline manufacturing process.",
    "status": "in progress"
}

NB. There is no longer a workspace_id field.

3. Create tasks (using the returned project id)

POST https://api.taskml.com/tasks

Using Authorization header, and JSON data like:

{

"name": "Update design",
"description": "Update model 3 design using latest design cues from Model S Plaid.",
"status": "in progress",
"project_id": 1

}

I will create real documentation in future, apologies if things are a bit confusing in the meantime.

T
tyro 10 months ago

Heads up, all api routes now live at taskml.com/api rather than api.taskml.com.

e.g. https://taskml.com/api/tasks

This is because Iā€™m adding some web endpoints (for sign up/login etc) and donā€™t want to run multiple servers.

D
dorianmariefr 10 months ago

image.png the first link doesnā€™t work

D
dorianmariefr 10 months ago

also there is no upload button on the comments WYSIWYG

D
dorianmariefr 10 months ago

not cool changing all the urls from api.taskml.com to taskml.com/api :(

D
dorianmariefr 10 months ago
~/s/god> curl -X "GET" "https://taskml.com/api/tasks" -H "Authorization: Bearer YOUR_API_KEY_HERE" -H "Content-Type: application/json"

{"errors":{"detail":"Invalid key"}}

nice

D
dorianmariefr 10 months ago

I donā€™t why the data has to be json but sure

~/s/god> curl --location 'https://taskml.com/api/users' \
             --header 'Content-Type: application/json' \
             --data '{
                 "email": "dorian+test@dorianmarie.fr",
                 "name": "dorianmariefr-test"
         }'
{"data":{"api_secret_key":"S...
D
dorianmariefr 10 months ago

creating projects works

~/s/god> curl --location 'https://taskml.com/api/projects' \
             --header 'Content-Type: application/json' \
             --data '{
                 "name": "God test",
                 "description": "Get god working test",
                 "status": "in progress"
         }' \
T
tyro 10 months ago

Hey @dorianmariefr, thanks for trying it out. šŸ™‚ Yep, sorry the URL was changed, everything is a bit in flux at the moment.

Btw, if you have dev plugin access on ChatGPT, you can also try it out there: Plugins -> Install unverified plugin.

D
dorianmariefr 10 months ago

I will try the plugin.

I just want to finish testing the API first.

It seems like it doesnā€™t return the created users

~/s/god> curl --location 'https://taskml.com/api/users' \
             --header 'Content-Type: application/json' \
              -H "Authorization: Bearer "
{"data":[]}
D
dorianmariefr 10 months ago

I canā€™t create tasks for my projects:

 ~/s/god> curl --location 'https://taskml.com/api/projects' \
             --header 'Content-Type: application/json' \
             --data '{
                 "name": "God test",
                 "description": "Get god working test",
                 "status": "in progress"
         }' \
             -H "Authorization: Bearer ..."
{"data":{"description":"Get god working test","id":7,"name":"God test","status":"in progress"}}āŽ                                                                ~/s/god> curl "https://taskml.com/api/tasks" -H "Authorization: Bearer SF...." -H "Content-Type: application/json" \
             --data '{
                          "name": "Make it work with revendeye in France",
                          "description": "Webhook to receive and API call to send",
                          "status": "in progress",
                          "project_id": 7`
                  }'

Bad Request
D
dorianmariefr 10 months ago

I asked ChatGPT to make ruby code for creating tasks

Certainly! Hereā€™s an example of a Ruby script that creates tasks using the TaskML API:

require 'net/http'
require 'json'

# API endpoint
url = URI.parse('https://taskml.com/api/tasks')

# API key for authorization
api_key = 'YOUR_API_KEY'

# Create a task
task_data = {
  name: 'Sample Task',
  description: 'This is a sample task created via the API.',
  status: 'in progress',
  project_id: 1 # Replace with the actual project ID
}

request = Net::HTTP::Post.new(url.path)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = task_data.to_json

response = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
  http.request(request)
end

if response.code == '201'
  puts 'Task created successfully!'
  task = JSON.parse(response.body)
  puts "Task ID: #{task['id']}"
else
  puts "Failed to create task. Error: #{response.body}"
end

Make sure to replace 'YOUR_API_KEY' with your actual API key, and update the project_id field with the ID of the project to which you want to assign the task.

When you run this script, it will send a POST request to the TaskML API to create a task. If the request is successful (status code 201), it will display the task ID. Otherwise, it will show an error message.

Note: This is a basic example to demonstrate the concept. In a real-world scenario, you may want to handle error cases more robustly and include error handling for network or connection issues.

D
dorianmariefr 10 months ago

(no Ctrl-Enter to submit comments?)

D
dorianmariefr 10 months ago
~/s/god> ruby a.rb 
Task created successfully!
Task ID: 
require 'net/http'
require 'json'
require 'dotenv/load'

# API endpoint
url = URI.parse('https://taskml.com/api/tasks')

# API key for authorization
api_key = ENV.fetch("KEY")

# Create a task
task_data = {
  name: 'Sample Task',
  description: 'This is a sample task created via the API.',
  status: 'in progress',
  project_id: 7 # Replace with the actual project ID
}

request = Net::HTTP::Post.new(url.path)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = task_data.to_json

response = Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
  http.request(request)
end

if response.code == '201'
  puts 'Task created successfully!'
  task = JSON.parse(response.body)
  puts "Task ID: #{task['id']}"
else
  puts "Failed to create task. Error: #{response.body}"
end
D
dorianmariefr 10 months ago

So looking good

T
tyro 10 months ago

Hey!

It seems like it doesnā€™t return the created users

There may be an authorisation issue here. /users will only return users who have projects in common with you. This is similar to e.g. /tasks which returns all tasks in projects you are involved with.

I canā€™t create tasks for my projects

Hmm. Iā€™m not sure the issue here. Possible things that can go wrong:

  1. Your access key does not have permission to edit that project (you must be a project user to add tasks to a project)
  2. The project_id is incorrect/doesnā€™t exist

Note that when you create a project, you are automatically added as a project user for that project, but for other users, they have to be added manually. i.e.

curl "https://taskml.com/api/project_users" -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/json" \
--data '{
    "user_id": 1,
    "project_id": 2
}'
Following
C
D
N
T
Follow You're not tracking this item.