Adding Web Services

To add a Web Service in AutoWeb you have to go to Web Service API description page and find info about the API.

Check out this video example if you like to follow videos, or check below for the full documentation.

I’m going to use the Spotify API as an example to illustrate most of the info here.

Step 1: Start Creating

  • Open AutoWeb
  • Touch “Your Web Services”
  • Press the + sign
  • Select the “Create” option

Creating API step 1

 

Step 2: API Details

  • Name: Spotify – give the API a name. Usually just the name of the website/app/company it’s based on.
  • Description: Music Playing Service – just a nice description for the API that users will see when importing it.
  • Base URL: https://api.spotify.com/v1/ – Part of the URL that is always the same for every url you’ll call in this API. If you look in their endpoint reference page, Spotify says that their base url is https://api.spotify.com. However you can see that all their endpoints (API Actions) start with /v1/ as well. So, in this case you can append the “v1” part in AutoWeb too. The base URL should always end in /. If the API has the “Secret Key” authentication type and that secret key is part of the base URL (ie, it’s included in every API call’s url, before the rest of the parameters like in the Weather Underground API, use {secretkeyautotools} as a placeholder for the key. More info here.
  • Image URL: https://lh3.googleusercontent.com/UrY7BAZ-XfXGpfkeWg0zCCeo-7ras4DCoRalC_WXXWTK9q5b0Iw7B0YQMsVxZaNB7DM=w300-rwA public URL with an icon that represents the service. A good way to get an icon is by going into the app’s google play listing, right clicking on the icon and choosing “Copy image address” and use that.
  • Works With No Auth: not checked – If the app has a way to work with no authentication, check this. This is true for the Kodi API for example, where a user can use it with Username And Password authentication, or with none at all

Step 3: Authentication

authentication

Authentication in an API allows it to know which user is acting.

A website with an API usually gives you a way to create your own “Application” whose details can then be used in AutoWeb. For example, to use the Spotify API you need to create an application here and then use that application’s details in the AutoWeb configuration.

When creating the application it’s very important to set the redirect URL to autoweb://auth

AutoWeb supports various types of authentication (click on the authentication name to see examples and more details about each one):

  • No Authentication – website doesn’t need any kind of special key or personal secret to access. You simply access it and get back some data
  • Username and Password – website requires basic HTTP authentication.
  • Secret Key – Website requires you to use a generated API key to access it. This usually serves to control access and restrict quotas. Usually an API key can only call a service X times an hour/day.
  • OAuth 2.0 – Website requires AutoWeb to be able to sign-in on behalf of the user so it can access its personal information. For example, in the Spotify API AutoWeb has to sign in with your user so that it can change the songs in your playlists. In this variation you’ll need to use the Client ID in AutoWeb. This is the preferred form of OAuth 2.0 in AutoWeb because no secret information is used thus making the API ready to be used by everyone.
  • OAuth 2.0 with refresh – Website requires AutoWeb to be able to sign-in on behalf of the user but needs a “Client Secret” to do so, besides the aforementioned “Client ID”. On some web services this is the only variant of OAuth 2.0. The downside is that you have to you your “Client Secret” which usually has limited quotas associated with it, like the “Secret Key” authentication method
  • Google – Most Google APIs can be used with this authentication method. Like OAuth 2.0 this won’t require any setting up for the end user so use it whenever possible.

To find out what type of authorization an API needs, search somewhere on the API website for details about authentication.

Authentication Intructions

Fill these in to let users know how to get the Secret Key or OAuth 2.0 with refresh Client Secret in APIs that need them. These will show up when the user first imports the API into AutoWeb and is asked to enter these details if they are not present.

 

Safeguard Sensitive Info

Check this option if you do not wish to share the Secret Key or OAuth 2.0 with refresh Client Secret values with other users when you share this API with them. If you select this option, the values for these fields will be removed before sharing the API. If you don’t see any problem with keeping these values, keep this option unchecked.

 

Step 4: Add API Actions

Most API actions can be added with the built-in helper. Let’s see how it works:

  • Click on the created API to go to the API Actions screen
  • Click the + sign on the top right
  • Answer “YES”, that you want help
  • Let’s add the Categories endpoint
  • As you can see, the endpoint URL is https://api.spotify.com/v1/browse/categories so just set the Example url for the action field in AutoWeb to that.
  • Click Ok.
  • AutoWeb will now ask you if the various parts of the url are variables. In this case there is nothing in the URL that can change between API calls (there’s no input, it’s just a simple call to the URL) so always answer that there is no variable
  • Name the action “Browse Categories”
  • Give it a description like “Get a list of categories used to tag items in Spotify”
  • Like you can see in the Spotify webpage, this request is of the “GET” type, so select that when prompted for the “Request Type”
  • You can now automatically generate the output for this API action. Answer yes to the generate output question.
  • Since this action has no input just accept it. If there was any input you would insert it here before calling the API
  • After the call you get a list of fields and headers. Fields are automatically selected but headers are not because you usually only care about an API’s fields. Select the fields you want and accept
  • If you now click on the API action and select “Output” you’ll see all the generated fields

Step 5: Optionally Add Inputs and Outputs

  • See here how to add inputs
  • See here how to add outputs

Step 6: Call API actions

The API action is now created and can be called from Tasker.

  • Open Tasker
  • Create a new task
  • Add an “AutoWeb Web Service” action
  • Under API select “Spotify”
  • Under API Action select “Browse Categories”
  • Under Fields to Get select the outputs you want. For example “Name”.
  • Since there are no inputs, accept the action
  • Go back to Tasker and add a “Flash” action
  • Set the Text field to %name()
  • Run the task and you should see a list of category names appear on the screen