Wave API - how to check subscriptions via API ?

Solved
ezzakyyy

Aug 18th, 2022 06:32 PM

Hey guys, Based on : https://wave.devdojo.com/docs/features/api

how we can check what subscription plan the user has via API ? and what Roles he has.

also how to allow users upload media files via API ?

thanks

bobbyiliev

Aug 19th, 2022 09:45 AM

Best Answer

Hi there,

You can use the users endpoint to get data for a specifc user. for example, let's say that you wanted to get some data about your user with ID 1, you could use the following request:

curl -X GET wave2.bobby.sh/api/users/1  -H "Authorization: Bearer ${token}"

This will return all of the data for that specific user, eg:

{
  "id": 1,
  "role_id": 1,
  "name": "Demo user 123",
  "email": "[email protected]",
  "avatar": "users/May2022/T4B2Liv9VvevROrfRGye.png",
  "email_verified_at": null,
  "password": "$encoded_pass",
  "remember_token": "some_token",
  "settings": {
    "locale": null
  },
  "created_at": "2017-11-21T16:07:22.000000Z",
  "updated_at": "2022-05-31T12:31:34.000000Z",
  "username": "admin",
  "stripe_id": null,
  "card_brand": null,
  "card_last_four": null,
  "trial_ends_at": null,
  "verification_code": null,
  "verified": 1,
  "test": null
}

For example, that user has role_id 1 which you could again check via the API if needed:

curl -X GET wave_url.com/api/roles/1  -H "Authorization: Bearer ${token}"

Output:

{
  "id": 1,
  "name": "admin",
  "display_name": "Admin User",
  "created_at": "2017-11-21T16:23:22.000000Z",
  "updated_at": "2017-11-21T16:23:22.000000Z"
}

I don't think that the media upload functionality is allowed via the API by default, but you should be able to extend that if needed by adding a new API endpoint.

Hope that this helps!

Best,

Bobby

Report
1