Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API V3: get report list, details & data #151

Merged
merged 2 commits into from
May 10, 2021
Merged

Conversation

ochorocho
Copy link
Contributor

Will add two additional endpoints:

  • /api/2.0/dataset/list - Lists all available reports
  • /api/2.0/dataset/{datasetId}/detail - Lists details about report including metadata, header, dimensions and available series.

@Rello Rello added this to the 3.5.0 milestone May 8, 2021
@Rello
Copy link
Owner

Rello commented May 8, 2021

Hello @ochorocho
thank you for this pull. nice idea

I have a question regarding detail: in fact this is mixing report header data and transactional data.
I have another todo for a pure getData
What do you think about keeping the data out of detail and put this in a second api-call?
would this also work for you? form design point of view its more modular to get the report header once and then the data e.g. on a regular basis

@ochorocho
Copy link
Contributor Author

@Rello ok, reworked the 'detail' endpoint. So there is one endpoint for getting reports details about header, dimensions and series of a report. On top of that I've added a addtitional enpoint /apps/analytics/api/2.0/dataset/{datasetId}/data which also respects filteroptions.

So i can fire 2 requests. 'details' for building a form in my client app, 'data' can then be used to build the chart :-)

@Rello
Copy link
Owner

Rello commented May 9, 2021

I will double check. thank you!
may I ask what you are using the API for?

@ochorocho
Copy link
Contributor Author

Working on a NativeScript/vue based android app supposed to manually track data.

@ochorocho
Copy link
Contributor Author

I will double check. thank you!
may I ask what you are using the API for?

This is what i got so far https://github.com/ochorocho/nextcloud-analytics-mobile
Can't promise anything.

@Rello
Copy link
Owner

Rello commented May 9, 2021

do you have any screenshots or teaser?
I don´t have android. if you get it going, I am more than happy to include the references/advertising in the this app

@Rello Rello merged commit 0c3cf2f into Rello:master May 10, 2021
@Rello Rello changed the title Add API endpoints to get list of available reports and reports details REST API: get report list, details & data May 10, 2021
@Rello
Copy link
Owner

Rello commented May 10, 2021

Hi,
i looked at the api routes and also other NC apps.
I think a cleanup (backwards compatible) would make sence.
what do you think?

POST /api/2.0/data/{datasetId}/add => ApiData#addDataV2
POST /api/2.0/data/{datasetId}/delete => ApiData#deleteDataV2
GET /api/2.0/data/{datasetId} => ApiData#getData (from you)

GET /api/2.0/datasets => ApiData#datasetIndex (from you)
GET /api/2.0/datasets/{datasetId} => ApiData#datasetDetail (from you)

Future:
DELETE /api/2.0/datasets/{datasetId} => ApiData#datasetDelete
...

@ochorocho
Copy link
Contributor Author

Yep, makes sense to me.

@Rello Rello changed the title REST API: get report list, details & data REST API V3: get report list, details & data May 11, 2021
Rello added a commit that referenced this pull request May 11, 2021
@Rello
Copy link
Owner

Rello commented May 11, 2021

Hello,
I updated the documentation
https://github.com/Rello/analytics/wiki/API

I did the cleanup and moved your part to the V3 to be consistent.
you would need to adapt your app one more time

    ['name' => 'ApiData#dataAddV3', 'url' => '/api/3.0/data/{datasetId}/add', 'verb' => 'POST'],
    ['name' => 'ApiData#dataDeleteV3', 'url' => '/api/3.0/data/{datasetId}/delete', 'verb' => 'POST'],
    ['name' => 'ApiData#dataGetV3', 'url' => '/api/3.0/data/{datasetId}', 'verb' => 'GET'],
    ['name' => 'ApiData#datasetsIndexV3', 'url' => '/api/3.0/datasets', 'verb' => 'GET'],
    ['name' => 'ApiData#datasetsDetailV3', 'url' => '/api/3.0/datasets/{datasetId}', 'verb' => 'GET'],

let me know if everything works for you

@Rello
Copy link
Owner

Rello commented May 15, 2021

@ochorocho
what is the reason that you use transaction data for the dataset detail?
The report metadata itself (like title, subtitel, dimensiton names, ...) is the correct one here. what was your reason for your implementation?

@ochorocho
Copy link
Contributor Author

Which endpoint are we talking about?

https://github.com/Rello/analytics/wiki/API#datasetsdetail

Gives me the required data including the series. I wanted to build up a form using the JSON data.

{
    "header": [
        "Object",
        "Date",
        "Value"
    ],
    "dimensions": {
        "dimension1": "Object",
        "dimension2": "Date"
    },
    "series": [ <-- Used to build a Form for each line/bar on the chart
        "MwH OG",
        "MwH UG"
    ]
}

@ochorocho
Copy link
Contributor Author

let me know if everything works for you

Works as expected. Thank you :-)

@Rello
Copy link
Owner

Rello commented May 16, 2021

Hello,
I enhanced it, because the report metadata itself definately needs to be in there (like types, chart/table, filters, ...)

`{
"options":
{"id":365,"name":"New","type":2,"visualization":"ct","chart":"column","parent":0,"dimension1":"Object","dimension2":"Date","subheader":"","chartoptions":"","dataoptions":"","filteroptions":null,"value":"Value","permissions":2},

"header":["Object","Date","Value"],

"dimensions":{"dimension1":"Object","dimension2":"Date"},

"series":["y"]
}
`

Rello added a commit that referenced this pull request May 16, 2021
@Rello Rello mentioned this pull request May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants