Youโ€™re the Expert!

pynfinity

API Playground

API Playground

Test and explore REST APIs with ease

REST API Testing Learning Platform

Request Configuration

https://pynfinity.com/welcome/testapi

Response

No response yet

Configure your request and click send to see the response here

API Documentation

GET Examples

/testapi/json /testapi/json2 /testapi/text /testapi/xml /testapi/<data-type>/<status-code> /testapi/QP?user=santosh&website=pynfinity

POST Examples

/testapi/post

Supports JSON, Form Data, and URL Encoded payloads.

{ "key": "value" }

PUT/PATCH/DELETE

/testapi/3b4c5d6e-7f8a-9b0c-1d2e-3f4a5b6c7d8e /testapi/7c8d9e0f-1a2b-3c4d-5e6f-7a8b9c0d1e2f/202

Use "id" as identifier | target-structure is /testapi/json2

API Authentication Details

APIKEY

i.wish.i.know.pynfinity.b4 iLoveUsingPynfinity

Basic

USERNAME:admin PASSWORD:pynfinity

Bearer Token

Generate token using /testapi/token

Token Expires in 60 minutes

Quick Method Examples

GET JSON Objects

Fetch a mocked JSON payload to test your UI integration.

POST Form Data

Test sending standard form submissions dynamically.

PUT Update Record

Send a full object update to a unique identifier.

What is a REST API? (Explained for Beginners!) ๐ŸŒ

Imagine you are sitting at a restaurant. You want a burger. You don't go to the kitchen to cook it yourself. Instead, you tell the waiter your order, the waiter takes it to the kitchen, and brings your burger back to your table.

A REST API (Representational State Transfer) is exactly like that waiter. It's a popular, lightweight way for two computer programs to talk to each other over the internet. Your program (the customer) sends a request to a server (the kitchen), and the server sends back the data you asked for (the burger).

The "Verbs" of REST (What do you want to do?) ๐ŸŽฌ

When you talk to a REST API, you use standard "HTTP Methods" (verbs) to explain what you want to achieve:

GET

READ: "Give me information." (e.g., Get my user profile or get the weather).

POST

CREATE: "Here is some new info, save it." (e.g., Create a new account).

PUT

UPDATE: "Change this existing info." (e.g., Update my email address).

DELETE

REMOVE: "Delete this info." (e.g., Delete my old photo).

JSON: The Universal Language ๐Ÿ“œ

While SOAP uses a strict language called XML, REST almost always uses JSON (JavaScript Object Notation). It looks exactly like a Python Dictionary! It's super easy for humans to read and computers to process.

{
    "username": "santoshtvk",
    "score": 9000,
    "is_active": true
}

How to Use REST APIs in Python ๐Ÿ

Python has an amazing, magical library called requests that makes talking to REST APIs incredibly simple. By far, it is the most popular library you will ever use in Python!

Step 1: Install it

pip install requests

Step 2: Basic Example (GET Request)

Let's try to "GET" some data from an API (like checking the weather).

import requests

# 1. Ask the server for data
response = requests.get("https://pynfinity.com/welcome/testapi/json")

# 2. Check if the server says '200 OK' (meaning Success!)
if response.status_code == 200:
    # 3. Convert the JSON answer into a Python Dictionary
    data = response.json()
    print(f"First content id is: {data[0]['id']}")

Step 3: Advanced Example (POST Request with Security Base)

When creating a new user or buying an item, we use POST. We also need to send SECURE headers, like an API Key, to prove who we are!

import requests

url = "https://api.example.com/v1/posts"

# The data we want to send (like filling out a form)
payload = {
    "title": "Learning REST APIs",
    "body": "This is so much easier than I thought!"
}

# Secret IDs/Passes go in the Header
headers = {
    "Authorization": "Bearer SUPER_SECRET_TOKEN_123",
    "Content-Type": "application/json"
}

# We use requests.post() instead of .get()
response = requests.post(url, json=payload, headers=headers)

if response.status_code == 201: # 201 means "Created"
    print("Successfully created the post!")

Why REST? ๐Ÿš€

  • It's Lightweight: JSON files are much smaller and easier to read than SOAP's heavy XML envelopes.
  • It's Extremely Flexible: You can use REST inside mobile apps (iOS/Android), web browsers (React, Angular), and backend servers.
  • It's the Modern Standard: 90% of the internetโ€™s public APIs (Google, Twitter, Stripe, Spotify) are built using REST.

Practice making GET, POST, and PUT requests yourself using the Playground above! ๐Ÿ’ป



Pynfinity
Install Pynfinity Add to home screen for the best experience