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.

Robot script

*** Settings ***
Documentation     HTTP API robot. Retrieves data from SpaceX API. Demonstrates
...               how to use RPA.HTTP (create session, get response, validate
...               response status, pretty-print, get response as text, get
...               response as JSON, access JSON properties, etc.).
Library           RPA.HTTP
Library           RPA.core.notebook
Suite Setup       Setup
Suite Teardown    Teardown

*** Variables ***
${SPACEX_API_LATEST_LAUNCHES}=    /launches/latest

*** Keywords ***
    Create Session    spacex    ${SPACEX_API_BASE_URL}    verify=True

*** Keywords ***
    Delete All Sessions

*** Keywords ***
Log latest launch
    ${launch}=    Get latest launch
    Log info    ${launch}

*** Keywords ***
Get latest launch
    ${response}=    Get Request    spacex    ${SPACEX_API_LATEST_LAUNCHES}
    Request Should Be Successful    ${response}
    Status Should Be    200    ${response}
    [Return]    ${response}

*** Keywords ***
Log info
    [Arguments]    ${response}
    ${pretty_json}=    To Json    ${response.text}    pretty_print=True
    ${launch}=    Set Variable    ${response.json()}
    Notebook Print    ${pretty_json}
    Log    ${pretty_json}
    Notebook Print    ${launch["mission_name"]}
    Log    ${launch["mission_name"]}
    Notebook Print    ${launch["rocket"]["rocket_name"]}
    Log    ${launch["rocket"]["rocket_name"]}

*** Tasks ***
Log latest launch info
    Log latest launch

Example response:

  "crew": null,
  "details": "This mission will launch the eighth batch of operational Starlink satellites, which are expected to be version 1.0, from SLC-40, Cape Canaveral AFS. It is the ninth Starlink launch overall. The satellites will be delivered to low Earth orbit and will spend a few weeks maneuvering to their operational altitude of 550 km. This mission is expected to include rideshare payloads, SkySats 16-18, on top of the Starlink stack. The booster for this mission is expected to land an ASDS.",
  "flight_number": 96,
  "is_tentative": false,
  "last_date_update": "2020-06-11T04:25:39.000Z",
  "last_ll_launch_date": null,
  "last_ll_update": null,
  "last_wiki_launch_date": "2020-06-13T09:21:00.000Z",
  "last_wiki_revision": "9a320975-ab9b-11ea-8445-0e30d54c90e7",
  "last_wiki_update": "2020-06-11T04:25:39.000Z",
  "launch_date_local": "2020-06-13T05:21:00-04:00",
  "launch_date_source": "wiki",
  "launch_date_unix": 1592040060,
  "launch_date_utc": "2020-06-13T09:21:00.000Z",
  "launch_site": {
    "site_id": "ccafs_slc_40",
    "site_name": "CCAFS SLC 40",
    "site_name_long": "Cape Canaveral Air Force Station Space Launch Complex 40"
  "launch_success": true,
  "launch_window": 0,
  "launch_year": "2020",
  "links": {
    "article_link": "",
    "flickr_images": [""],
    "mission_patch": "",
    "mission_patch_small": "",
    "presskit": null,
    "reddit_campaign": "",
    "reddit_launch": "",
    "reddit_media": "",
    "reddit_recovery": "",
    "video_link": "",
    "wikipedia": "",
    "youtube_id": "8riKQXChPGg"
  "mission_id": [],
  "mission_name": "Starlink-8 & SkySat 16-18",
  "rocket": {
    "fairings": {
      "recovered": null,
      "recovery_attempt": true,
      "reused": true,
      "ship": "GOMSTREE"
    "first_stage": {
      "cores": [
          "block": 5,
          "core_serial": "B1059",
          "flight": 3,
          "gridfins": true,
          "land_success": true,
          "landing_intent": true,
          "landing_type": "ASDS",
          "landing_vehicle": "OCISLY",
          "legs": true,
          "reused": true
    "rocket_id": "falcon9",
    "rocket_name": "Falcon 9",
    "rocket_type": "FT",
    "second_stage": {
      "block": 5,
      "payloads": [
          "customers": ["SpaceX"],
          "manufacturer": "SpaceX",
          "nationality": "United States",
          "norad_id": [],
          "orbit": "VLEO",
          "orbit_params": {
            "apoapsis_km": null,
            "arg_of_pericenter": null,
            "eccentricity": null,
            "epoch": null,
            "inclination_deg": null,
            "lifespan_years": null,
            "longitude": null,
            "mean_anomaly": null,
            "mean_motion": null,
            "periapsis_km": null,
            "period_min": null,
            "raan": null,
            "reference_system": "geocentric",
            "regime": "very-low-earth",
            "semi_major_axis_km": null
          "payload_id": "Starlink 8",
          "payload_mass_kg": 15400,
          "payload_mass_lbs": 33951.2,
          "payload_type": "Satellite",
          "reused": false
  "static_fire_date_unix": null,
  "static_fire_date_utc": null,
  "tbd": false,
  "telemetry": {
    "flight_club": null
  "tentative_max_precision": "hour",
  "timeline": null,
  "upcoming": false

Learn more about the libraries mentioned on this page:

December 7, 2020