Skip to main content

HTTP Methods

RestAPI.com supports standard HTTP methods for CRUD operations on your data.

GET — Retrieve Data

Retrieve items from a collection or a specific item by ID.

Get All Items

GET https://eu.restapi.com/my-api/products

Get Single Item

GET https://eu.restapi.com/my-api/products/b320fe87-8d9b-47a5-bf1b-8df8320ab94e

Query Parameters

ParameterDescriptionExample
filterFilter results?filter=price gt 100
sortBySort results?sortBy=name or ?sortBy=name- (descending)
selectChoose fields?select=name,price
pageNoPage number?pageNo=2
pageSizeItems per page (default: 10)?pageSize=20
countInclude total count in response?count=true
important

The default page size is 10 items. If you need more items per request, specify pageSize explicitly (e.g., ?pageSize=100). Maximum page size is 1000.

Count Parameter

When count=true is specified, the response includes the total item count in a meta property:

{
"meta": {
"count": 143
},
"items": [
{ "id": "...", "name": "Widget Pro", "price": 29.99 },
{ "id": "...", "name": "Widget Plus", "price": 39.99 }
]
}

This is useful for pagination — you can calculate total pages from the count and your page size.

Filtering

Use comparison operators to filter results:

OperatorDescriptionExample
eqEqual toname eq "Widget"
neNot equal tostatus ne "deleted"
gtGreater thanprice gt 100
ltLess thanstock lt 10
conContains (strings)name con "pro"
nconNot contains (strings)name ncon "test"
swStarts with (strings)name sw "Pro"
ewEnds with (strings)name ew "Plus"

Combine conditions:

?filter=price gt 100 and category eq "Electronics"
?filter=status eq "active" and (priority eq "high" or priority eq "urgent")

Case-insensitive matching: Append ~ to the operator:

?filter=name eq~ "widget"

Sorting

?sortBy=name        # Ascending
?sortBy=name- # Descending
note

Only single-property sorting is currently supported.

Selecting Fields

Return only specific properties:

?select=name,price,category

The id property is always included. Nested lookup fields use dot notation:

?select=name,category.name

POST — Create Items

Create one or more items in a collection.

Single Item

POST https://eu.restapi.com/my-api/products
Content-Type: application/json

{
"name": "Widget Pro",
"price": 29.99,
"category": "Electronics"
}

Response: 201 Created with the new item's ID:

{
"data": ["ebe5c3e8-ad03-4605-bcf8-2060e75ff9c7"]
}

Multiple Items

POST https://eu.restapi.com/my-api/products
Content-Type: application/json

[
{ "name": "Widget Pro", "price": 29.99 },
{ "name": "Widget Plus", "price": 39.99 }
]

Response: 201 Created with the new item IDs in the same order as the request:

{
"data": [
"ebe5c3e8-ad03-4605-bcf8-2060e75ff9c7",
"a1b2c3d4-5678-90ab-cdef-1234567890ab"
]
}

Multiple items are created atomically. If any item fails validation, none are created.

Notes

  • Property names are case-sensitive
  • Unknown properties are ignored
  • Missing properties receive default values or null
  • Items receive auto-generated GUID IDs

Nested Children

Create a parent item with its children in a single atomic request using dot notation:

POST https://eu.restapi.com/my-api/products
Content-Type: application/json

{
"sku": "WIDGET-001",
"name": "Widget Pro",
"variants.product": [
{ "color": "red", "price": 29.99 },
{ "color": "blue", "price": 31.99 }
]
}

The pattern variants.product means: create items in the variants collection where the product field points to this parent.

note

Nested children are limited to one level of depth.

Nested Children with Security Policies

When using security policies, you may need to create nested children that reference the current user or other lookup values. Include the id property for lookup references:

POST https://eu.restapi.com/my-api/company
Content-Type: application/json

{
"name": "Acme Corp",
"companyUser.company": [
{
"user": { "id": "current-user-id" },
"role": { "id": "admin-role-id" }
}
]
}

This creates a company and simultaneously creates a companyUser record linking the current user to the new company with a specific role — useful for granting access to the newly created item.

See Nested Children for more details.


PUT — Replace Item

Replace an entire item. Existing values are not preserved.

PUT https://eu.restapi.com/my-api/products/b320fe87-8d9b-47a5-bf1b-8df8320ab94e
Content-Type: application/json

{
"name": "Widget Pro v2",
"price": 34.99,
"category": "Electronics"
}

Response: 200 OK on success, 404 Not Found if item doesn't exist.

warning

PUT replaces the entire item. Properties not included in the request will be set to their default values or null. Use PATCH for partial updates.

Nested Children

Replace a parent item and manage its children atomically:

PUT https://eu.restapi.com/my-api/products/b320fe87-8d9b-47a5-bf1b-8df8320ab94e
Content-Type: application/json

{
"sku": "WIDGET-001",
"name": "Widget Pro v2",
"variants.product": [
{ "id": "existing-variant-id", "color": "red", "price": 32.99 },
{ "color": "green", "price": 34.99 }
]
}
  • Items with an id are updated
  • Items without an id are created
  • Existing children not included in the array are deleted
note

Nested children are limited to one level of depth.


PATCH — Update Item

Modify specific properties of an item. Existing values are preserved.

PATCH https://eu.restapi.com/my-api/products/b320fe87-8d9b-47a5-bf1b-8df8320ab94e
Content-Type: application/json

{
"price": 34.99
}

Response: 200 OK on success, 404 Not Found if item doesn't exist.

Nested Children

Update a parent and manage its children in a single atomic request:

PATCH https://eu.restapi.com/my-api/projects/abc-123
Content-Type: application/json

{
"name": "Updated Project Name",
"tasks.project": [
{ "id": "task-1", "title": "Design", "status": "completed" },
{ "id": "task-2", "title": "Development", "status": "in-progress" },
{ "title": "New Task", "status": "pending" }
]
}

The behavior is the same as PUT for nested children:

ScenarioAction
Item has idUpdated
Item has no idCreated
Existing item not in arrayDeleted

All operations happen within a single transaction. If any operation fails, everything is rolled back.

note

Nested children are limited to one level of depth.


DELETE — Remove Items

Delete one or more items from a collection.

Single Item

DELETE https://eu.restapi.com/my-api/products/b320fe87-8d9b-47a5-bf1b-8df8320ab94e

Response: 204 No Content on success, 404 Not Found if item doesn't exist.

Multiple Items (Bulk Delete)

Delete multiple items in a single request by sending an array of IDs:

DELETE https://eu.restapi.com/my-api/products
Content-Type: application/json

[
"b320fe87-8d9b-47a5-bf1b-8df8320ab94e",
"a1b2c3d4-5678-90ab-cdef-1234567890ab",
"f9e8d7c6-5432-10fe-dcba-0987654321fe"
]

Response: 204 No Content on success.

Bulk delete operations are atomic — all items are deleted or none are.