HTTP API robot

Get the code and run this example in your favorite editor on our Portal!

SpaceX logo

This simple software robot fetches and logs the latest launch data from SpaceX API using RPA Framework.

See HTTP request method examples for more examples on using HTTP request methods (DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT) with Robot Framework.

RPA Framework version 14.1.1 or newer is recommended!

Robot script

*** Settings *** Documentation HTTP API robot. Retrieves data from SpaceX API. Demonstrates ... how to use RPA.HTTP (get response, validate response status, ... get response as JSON, access JSON properties, etc.). Library RPA.HTTP *** Variables *** ${SPACEX_API_LATEST_LAUNCHES_URL}= *** Tasks *** Log latest launch info Log latest launch *** Keywords *** Log latest launch ${launch}= Get latest launch Log info ${launch} Get latest launch ${response}= GET ${SPACEX_API_LATEST_LAUNCHES_URL} Request Should Be Successful Status Should Be 200 RETURN ${response} Log info [Arguments] ${response} ${launch}= Set Variable ${response.json()} Log ${launch} Log ${launch["name"]} Log ${launch["links"]["reddit"]["campaign"]}

Example response:

{ "fairings": { "reused": true, "recovery_attempt": true, "recovered": true, "ships": ["60c8c7a45d4819007ea69871"] }, "links": { "patch": { "small": "", "large": "" }, "reddit": { "campaign": "", "launch": "", "media": null, "recovery": "" }, "flickr": { "small": [], "original": [ "", "", "", "", "", "", "", "" ] }, "presskit": null, "webcast": "", "youtube_id": "sSiuW1HcGjA", "article": null, "wikipedia": null }, "static_fire_date_utc": "2021-06-22T15:24:00.000Z", "static_fire_date_unix": 1624375440, "tbd": false, "net": false, "window": 0, "rocket": "5e9d0d95eda69973a809d1ec", "success": true, "details": "Falcon 9 launches to sun-synchronous polar orbit from Florida as part of SpaceX's Rideshare program dedicated to smallsat customers. The mission lifts off from SLC-40, Cape Canaveral on a southward azimuth and performs a dogleg maneuver. The booster for this mission is expected to return to LZ-1 based on FCC communications filings. This rideshare takes approximately 90 satellites and hosted payloads into orbit on a variety of deployers including three free-flying spacecraft which dispense their customers' satellites after separation from the SpaceX stack.", "ships": ["60c8c7a45d4819007ea69871"], "capsules": [], "payloads": ["608ac397eb3e50044e3630e7"], "launchpad": "5e9e4501f509094ba4566f84", "auto_update": true, "launch_library_id": "5d248abe-17ef-43ce-9c04-aef33af40520", "failures": [], "crew": [], "flight_number": 132, "name": "Transporter-2", "date_utc": "2021-06-30T19:31:00.000Z", "date_unix": 1625081460, "date_local": "2021-06-30T15:31:00-04:00", "date_precision": "hour", "upcoming": false, "cores": [ { "core": "5ef670f10059c33cee4a826c", "flight": 8, "gridfins": true, "legs": true, "reused": true, "landing_attempt": true, "landing_success": true, "landing_type": "RTLS", "landpad": "5e9e3032383ecb267a34e7c7" } ], "id": "600f9b6d8f798e2a4d5f979f" }
Last edit: May 17, 2022