ଏହି କଣ୍ଟ‍୍ରୋଲ୍‌କୁ ପରିବର୍ତ୍ତନ କରିବା ଫଳରେ ଏହି ପୃଷ୍ଠା ସ୍ବୟଂଚାଳିତ ଭାବରେ ଅପ୍‌ଡେଟ୍ ହୋଇଯିବ

Request your first API in Shortcuts

To request your first API, you create the URL that points at the API “endpoint” that you want to talk to and then pass that URL to the Get Contents of URL action. When the shortcut is run, this action makes the API request.

A Dark Sky API request that contains a Text action with a secret API key, followed by a URL action pointing at the API endpoint using a Secret Key variable, followed by a Get Contents of URL action.

Build the API request

Dark Sky’s Forecast endpoint requires a URL request to be formatted as such:

https://api.darksky.net/forecast/[YOUR_SECRET_KEY]/[LAT],[LONG]

The text in brackets will be filled out with an API key and the location you want forecast data for.

  • In the Shortcuts app, place your API key from Dark Sky in the first Text action, which is passed to the URL action as a variable. The LAT and LONG values are already set to 37.8267 and -122.4233, which are the coordinates for Alcatraz Island in San Francisco. (You can change those values to a different location.)

    Try using the Get Current Location action and placing it as a Magic Variable set to Latitude and Longitude in the URL action to get local weather data whenever you run the shortcut.

    A Get Current Location action added between the Text action and the URL action in the Dark Sky API request shortcut.

Perform the API request with the Get Contents of URL action

  1. In the shortcut editor of the Shortcuts app, set Get Contents of URL to Advanced.

    The following options for the types of API requests you can make become available:

    • GET allows you to retrieve data.

    • POST allows you to create new data.

    • PUT allows you to update data by replacing it.

    • PATCH allows you to update data by modifying it.

    • DELETE allows you to remove an object specified in the URL request.

  2. For this example, use a GET request to retrieve data from the Dark Sky API.

    Now that the URL action has your request and the Get Contents of URL action is set up to GET data, you’re ready to make the API request.

    Note: When the Get Contents of URL action is switched to POST, PUT or PATCH, a new parameter called Request Body is added. Request Body allows you to send JSON, a Form or a File to the API as part of your request. This lets you enter new data manually or by using variables so you can send the data to the API for creating, replacing or modifying an entry.

  3. Tap to test the shortcut (the Quick Look action in the shortcut allows you to preview the data that the API returns).

    Results of the Dark Sky API request shortcut, showing the weather forecast for Alcatraz.

    Upon first look, the API appears to return a mess of text. This weather data is encoded in JSON, which stands for JavaScript Object Notation.

To learn about working with JSON and to continue with the Dark Sky API example, see Intro to using JSON in Shortcuts.

Not all apps, content and services are available in all areas.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.
ସହାୟକ କି?
କ‍୍ୟାରେକ୍ଟର୍ ସୀମା: 250
ସର୍ବାଧିକ କ‍୍ୟାରେକ୍ଟର୍ ସୀମା 250 ଅଟେ।
ଆପଣଙ୍କ ମତାମତ ପାଇଁ ଧନ‍୍ୟବାଦ।
Morty Proxy This is a proxified and sanitized view of the page, visit original site.