a-know / Pixela

A service for generating GitHub-like graphs. Record and Track your habits or effort. All by API.
https://pixe.la
402 stars 26 forks source link

[Request] Get "a" graph definition json #15

Closed budougumi0617 closed 3 years ago

budougumi0617 commented 3 years ago

I appreciate excellent product. Today, I have a request.

I want an endpoint that returns JSON for "a" graph for a specified ID.

Details: Now I'm implementing a terraform provider for Pixela.

https://github.com/budougumi0617/terraform-provider-pixela

To create a terraform provider, we need to be able to perform CRUD operations to the resources.

https://learn.hashicorp.com/tutorials/terraform/provider-use?in=terraform/providers

However, your service does not have an public endpoint to get the json of the definition for the specified graph. GET - /v1/users/<username>/graphs/<graphID> returns svg data.

Therefore, my implementation is using an alternative what I get the JSON for all the graph definitions and then search the graph information for a specified ID. even as the number of graphs defined by provider increases, this operation will be performed for each graph. This is an unnecessary operation and may put an extra load on the server.

I'd appreciate if you would examine this request.

Regards,

a-know commented 3 years ago

@budougumi0617 san, Thank you for your request! πŸ˜„ I have just released v1.21.0 that includes the requested API addition!

https://github.com/a-know/Pixela/releases/tag/v1.21.0

If this will satisfy your request, please close this issue. I'm looking forward to your request anytime! πŸ˜„

budougumi0617 commented 3 years ago

Thank you for your fast release! I got below response.

curl -X GET "https://pixe.la/v1/users/budougumi0617/graphs/egiu/graph-def" -H "X-USER-TOKEN:${PIXELA_TOKEN}" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   203  100   203    0     0    652      0 --:--:-- --:--:-- --:--:--   652
{
  "id": "egiu",
  "name": "English grammar in use",
  "unit": "unit",
  "type": "int",
  "color": "ajisai",
  "timezone": "Asia/Tokyo",
  "purgeCacheURLs": null,
  "selfSufficient": "none",
  "isSecret": true,
  "publishOptionalData": false
}

this is my wanted endpoint, thanks!!