robotframework-restinstance-skill

Guide AI agents in creating REST API tests using RESTinstance library. Use when building API tests with JSON Schema validation, built-in assertions, response field validation, and OpenAPI spec integration.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "robotframework-restinstance-skill" with this command: npx skills add manykarim/robotframework-agentskills/manykarim-robotframework-agentskills-robotframework-restinstance-skill

RESTinstance Library Skill

Quick Reference

RESTinstance is a REST API testing library with built-in JSON validation, schema support, and OpenAPI/Swagger spec integration. It provides a fluent interface for API testing with automatic response validation.

Installation

pip install RESTinstance

Library Import

*** Settings ***
Library    REST    ${API_URL}

Key Differentiators from RequestsLibrary

FeatureRESTinstanceRequestsLibrary
Built-in assertionsYesNo (use RF assertions)
JSON Schema validationYesNo (need JSONLibrary)
OpenAPI/Swagger supportYesNo
Response type validationYes (String, Integer, etc.)Manual
State managementAutomatic instance trackingSession-based

Basic Usage

Simple GET Request

GET    /users/1
Integer    response status    200
String     response body name    John
Integer    response body id    1

POST with JSON Body

POST    /users    {"name": "John", "email": "john@test.com"}
Integer    response status    201
Integer    response body id
String     response body name    John

Complete CRUD Example

*** Test Cases ***
CRUD User Lifecycle
    # Create
    POST    /users    {"name": "John"}
    Integer    response status    201
    ${id}=    Integer    response body id

    # Read
    GET    /users/${id}
    Integer    response status    200
    String    response body name    John

    # Update
    PUT    /users/${id}    {"name": "John Updated"}
    Integer    response status    200
    String    response body name    John Updated

    # Delete
    DELETE    /users/${id}
    Integer    response status    204

Core Keywords Quick Reference

HTTP Methods

KeywordUsageDescription
GETGET /endpointGET request
POSTPOST /endpoint {"json": "body"}POST with JSON
PUTPUT /endpoint {"json": "body"}Replace resource
PATCHPATCH /endpoint {"json": "body"}Partial update
DELETEDELETE /endpointDelete resource
HEADHEAD /endpointHeaders only
OPTIONSOPTIONS /endpointGet allowed methods

Response Validation Keywords

KeywordUsageDescription
IntegerInteger response status 200Validate integer value
StringString response body name JohnValidate string value
NumberNumber response body price 19.99Validate float/number
BooleanBoolean response body active trueValidate boolean
NullNull response body deleted_atValidate null value
ArrayArray response body itemsValidate array type
ObjectObject response body profileValidate object type
OutputOutput response bodyLog value (must exist)
MissingMissing response body errorValidate field absent

Response Validation

Status Code

GET    /users/1
Integer    response status    200

POST    /users    {"name": "Test"}
Integer    response status    201

DELETE    /users/1
Integer    response status    204

Body Fields

GET    /users/1

# Validate type only (any value)
String     response body name
Integer    response body id
Boolean    response body active

# Validate type AND value
String     response body name    John
Integer    response body age     30
Boolean    response body active  true

Nested Fields

# Response: {"user": {"profile": {"name": "John"}}}
GET    /users/1
String    response body user profile name    John
Integer   response body user id              1

Array Access

# Response: {"items": [{"id": 1}, {"id": 2}]}
GET    /items
Integer    response body items 0 id    1
Integer    response body items 1 id    2
String     response body items 0 name

Field Existence

GET    /users/1
Output     response body id      # Field must exist (logs value)
Missing    response body error   # Field must NOT exist

Headers and Authentication

Set Headers

Set Headers    {"Authorization": "Bearer ${TOKEN}"}
GET    /protected

Per-Request Headers

GET    /data    headers={"X-Custom": "value"}

Basic Auth

${credentials}=    Evaluate    base64.b64encode(b'${USER}:${PASS}').decode()    modules=base64
Set Headers    {"Authorization": "Basic ${credentials}"}
GET    /protected

Bearer Token

Set Headers    {"Authorization": "Bearer ${TOKEN}"}
GET    /users/me
Integer    response status    200

JSON Schema Validation

Inline Schema

GET    /users/1
Object    response body    {"type": "object", "required": ["id", "name"]}

Schema From File (Using Expect Response Body)

# Set expectation BEFORE the request
Expect Response Body    ${CURDIR}/schemas/user.json
GET    /users/1

Example Schema File (user.json)

{
  "type": "object",
  "required": ["id", "name", "email"],
  "properties": {
    "id": {"type": "integer"},
    "name": {"type": "string", "minLength": 1},
    "email": {"type": "string", "format": "email"},
    "active": {"type": "boolean"}
  }
}

Pattern Matching

Wildcard Matching

String    response body name    John*        # Starts with John
String    response body type    *_active     # Ends with _active
String    response body id      *abc*        # Contains abc

Regex Matching

String    response body email    /^[\\w.-]+@[\\w.-]+\\.\\w+$/
String    response body phone    /^\\+?\\d{10,}$/
String    response body uuid     /^[a-f0-9-]{36}$/

Common Patterns

API Test Structure

*** Settings ***
Library    REST    https://api.example.com

*** Test Cases ***
Get User By ID
    GET    /users/1
    Integer    response status    200
    String     response body name
    Integer    response body id    1
    Missing    response body error

Create User Successfully
    POST    /users    {"name": "Test", "email": "test@test.com"}
    Integer    response status    201
    String     response body name    Test
    Integer    response body id

Store and Reuse Values

*** Test Cases ***
Create And Verify User
    POST    /users    {"name": "John"}
    ${id}=    Integer    response body id

    GET    /users/${id}
    Integer    response body id    ${id}
    String     response body name    John

Validate Response Headers

GET    /users
String    response headers Content-Type    application/json*

Expectation Keywords (Schema Validation)

The correct way to validate responses against JSON Schema files is using expectation keywords BEFORE the HTTP request:

Expect Response Body

# Validate response body against a JSON Schema file
Expect Response Body    ${CURDIR}/schemas/user.json
GET    /users/1

Expect Response

# Validate the full response (status, headers, body) against a schema
Expect Response    ${CURDIR}/schemas/response.json
GET    /users/1

Expect Request

# Validate request body before sending
Expect Request    ${CURDIR}/schemas/create-user-request.json
POST    /users    {"name": "John", "email": "john@test.com"}

Clear Expectations

# Remove all previously set expectations
Clear Expectations
GET    /users/1    # No schema validation on this request

Client Configuration Keywords

SSL and Certificate Configuration

# Disable SSL verification
Set SSL Verify    ${False}
GET    /users

# Set client certificate for mTLS
Set Client Cert    ${CURDIR}/certs/client.pem
GET    /protected

# Set client authentication
Set Client Authentication    ${USERNAME}    ${PASSWORD}
GET    /protected

Query Parameters

# Pass query parameters as a dict using the query parameter
&{params}=    Create Dictionary    page=1    limit=10
GET    /users    query=${params}
# Results in: GET /users?page=1&limit=10

Disabling Automatic Validation

# Disable automatic schema validation for a single request
GET    /users/1    validate=False

When to Load Additional References

Load these reference files for specific use cases:

  • JSON Schema validation patterns -> references/schema-validation.md
  • JSON handling and manipulation -> references/json-handling.md
  • OAuth, JWT, API keys -> references/authentication.md
  • Full keyword listing -> references/keywords-reference.md
  • Error debugging -> references/troubleshooting.md

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

robotframework-appium-skill

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

robotframework-selenium-skill

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

robotframework-browser-skill

No summary provided by upstream source.

Repository SourceNeeds Review