Quickstart

The base URL for the Marvelly REST API is: https://api.marvelly.com.ng/v1

Configure Base URL

Depending on your environment and application, you will set the base URL differently. Below is a universal string that you can use to access our API. Copy it or return here later when you are ready with your environment or app.

Copy

https://api.marvelly.com.ng/v1

The REST API does not support both versioned URLs in your API requests. You can use only one of the following formats:

Using the main URLs can help ensure compatibility with future updates and changes to the API. It is recommended to use the base URLs for long-term projects to maintain stability.

Making Your First API Call

Based on your environment, you will call our API differently. Below are two common ways to call our API using two popular programming languages: PHP, Python and NodeJS.

Notes

  • Some GET request examples displayed throughout these docs are written for use with Node.js - the axios library may be required.

  • Some GET request examples displayed throughout these docs are written for use with Python - the request library may be required.

  • Some GET request examples displayed throughout these docs are written for use with PHP - the curl or Guzzle library may be required.

Making Your First API Call

Based on your environment, you will call our API differently. Below are three common ways to call our API using two popular programming languages: PHP, Python and NodeJS.

Example in Python

Let's start from very beginning. We assume you already installed Python (with venv), if not, here a guide for the beginners.

Create a new folder for test project, name it as aimlapi-welcome and change to it.

Copy

mkdir ./marvellyapi-welcome
cd ./marvelly-welcome

(Optional) If you use IDE then we recommend to open created folder as workspace. On example, in VSCode you can do it with:

Copy

code .

Run a terminal inside created folder and create virtual envorinment with a command

Copy

python3 -m venv ./.venv

Activate created virtual environment

Copy

# Linux / Mac
source ./.venv/bin/activate
# Windows
./.venv/bin/Activate.bat

Create new file and name it as api.py

Copy

touch api.py

Paste following content inside this travel.py and replace my_key with your API key you got on first step

Copy

import requests

# Define the API URL
url = "http://api.marvelly.com.ng/v1"

try:
    # Make a GET request to the API
    response = requests.get(url)
    
    # Check if the request was successful
    if response.status_code == 200:
        # Print the JSON response
        data = response.json()
        print(data)
    else:
        print(f"Failed to retrieve data. Status code: {response.status_code}")

except requests.exceptions.RequestException as e:
    # Print any errors that occur
    print(f"An error occurred: {e}")

Run the application

Copy

python3 ./api.py

If you done all correct, you will see following output:

Copy

{
  "message": "Welcome to API world"
}
Example in NodeJS

As in the example from Python, we start from the very beginning too. We assume you already have Node.js installed. If not, here is a guide for beginners.

We need to create a new folder for the example project:

Copy

mkdir ./marvelly-welcome
cd ./marvelly-welcome

(Optional) If you use IDE then we recommend to open created folder as workspace. On example, in VSCode you can do it with:

Copy

code .

Now create a project file:

Copy

npm init -y

Install the required dependencies:

Copy

npm i axios

Create a file with the source code:

Copy

touch ./index.js

And paste the following content:

Copy

const axios = require('axios');

// API URL
const url = 'http://api.marvelly.com.ng/';

// Make the GET request using axios
axios.get(url)
  .then(response => {
    // Handle successful response
    console.log('Response from API:', response.data);
  })
  .catch(error => {
    // Handle errors
    console.error('An error occurred:', error.message);
  });

You will see a response that looks like this:

Copy

{
  "message": "Welcome to API world"
}

Last updated

Was this helpful?