Complete beginner question - how do use an API?

Hi, I code in python and I’m a beginner. I want to know how to use an API but I’m not sure how to send in requests, what is the easiest way to send them? Is it possible to put them as an html file?

These are the examples I got from the API documentation, I have no idea where I’m supposed to enter them and how to combine them with python:

#!/bin/bash
clientId=“my_client_id”
secret=“my_secret”
curl -H “AuthClientId: ${clientId}” -H “AuthSecret: ${secret}”
“https://…”

<?php $clientId='my_client_id'; $secret='my_secret'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https:...."); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "AuthClientId: {$clientId}", "AuthSecret: {$secret}" )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $body = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); ?>

#!/bin/env powershell

$clientId = ‘my_client_id’
$secret = ‘my_secret’

$url = “https…”

$headers = @{
“AuthClientId” = $clientId;
“AuthSecret” = $secret;
}

try {
$result = Invoke-RestMethod -Uri $url -Headers $headers -Method GET
Write-Output $result
}
catch {
$errorvalue = $_.Exception.Response.StatusCode.Value__
Write-Output “Got Error $errorvalue”
}

Did you see the docs here?
http://documentation.xojo.com/topics/communication/internet/accessing_web_services.html

1 Like

Is this a Xojo question?

3 Likes

Hi sometimes its easier to think on paper and to start with sequence charts.
BR Rainer

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.