A project groups the tests of one website or app in Optisway, with its address and description. A key scoped to one project sees only that project; a key without a scope sees every project of the organisation.
Project
A project with its number of tests and its most recent run.
Fields: Project
Field
Type
Description
id
string
The project's id, a decimal string.
name
string
The project's name as shown in the app.
url
string
The website address the project covers.
description
string
The project's description; an empty string when none was written.
testCount
integer
How many tests the project holds.
lastRun
RunSummary | null
The newest run of any test in the project as a RunSummary, or null before the first run.
createdAt
ISO 8601 string
When the project was created (UTC).
updatedAt
ISO 8601 string
When the project was last changed (UTC).
links.self
string
The path of this project (GET /projects/{id}).
links.tests
string
The path that lists this project's tests (GET /tests?project={id}).
Lists the projects of the key's organisation; a project-scoped key sees only its own project. Needs read access, and the list is not paged. The example shows an organisation with one project, 42.
// Java 11+: save as Main.java and run `java Main.java`import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public classMain {
public static void main(String[] args) throwsException {
String url = "https://optisway.com/api/v1/projects";
HttpRequest request = HttpRequest.newBuilder(URI.create(url))
.header("Authorization", "Bearer " + System.getenv("OPTISWAY_API_KEY"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 300) {
String error = response.body();
System.err.println(response.statusCode() + " " + field(error, "error") + ": "
+ field(error, "message"));
System.exit(1);
}
// { "items": [...], "next": ... } -- any JSON library (Jackson, Gson, org.json) parses it;// this example stays dependency-free and prints the raw JSON.System.out.println(response.body());
}
/** The first string value of a JSON key (dependency-free; Jackson or Gson parse JSON properly). */static String field(String json, String key) {
Matcher match = Pattern.compile("\"" + key + "\"\\s*:\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|null)")
.matcher(json);
return match.find() ? match.group(1) : null;
}
}
package main
import (
"encoding/json""fmt""net/http""os"
)
func main() {
url := "https://optisway.com/api/v1/projects"
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPTISWAY_API_KEY"))
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode >= 300 {
var envelope struct {
Error string`json:"error"`
Message string`json:"message"`
}
_ = json.NewDecoder(resp.Body).Decode(&envelope)
fmt.Fprintf(os.Stderr, "%d %s: %s\n", resp.StatusCode, envelope.Error, envelope.Message)
os.Exit(1)
}
var body map[string]anyif err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
panic(err)
}
for _, raw := range body["items"].([]any) {
item := raw.(map[string]any)
fmt.Println(item["id"], item["name"])
}
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`usingSystem.Net.Http.Headers;
usingSystem.Net.Http.Json;
usingSystem.Text.Json;
using var client = newHttpClient();
client.DefaultRequestHeaders.Authorization =
newAuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/projects";
using var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
var error = envelope.GetProperty("error");
var message = envelope.GetProperty("message");
Console.Error.WriteLine($"{(int)response.StatusCode}{error}: {message}");
Environment.Exit(1);
}
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
foreach (var item in body.GetProperty("items").EnumerateArray())
{
Console.WriteLine(string.Join(" ",
item.GetProperty("id"), item.GetProperty("name")));
}
Example response
Returns: An object whose items array holds Project objects.
unauthorized401 The key is missing, malformed, unknown, revoked or expired, or its creator is no longer a member.
rate_limited429 The key sent too many requests; wait the seconds in Retry-After.
unavailable503 A temporary problem on our side; try again later.
Read a projectGET/projects/{id}
Reads one project by its numeric id. Needs read access; a project outside the key's scope answers 404 not_found, exactly like one that does not exist. The example reads project 42, whose lastRun is the failed run 4821.
Needs a key with access: Read
Parameters
Parameters: GET /projects/{id}
Name
In
Type
Required
Description
Example
id
Path
string (numeric project id)
Yes
The numeric id of the project, as returned in Project.id.
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`usingSystem.Net.Http.Headers;
usingSystem.Net.Http.Json;
usingSystem.Text.Json;
using var client = newHttpClient();
client.DefaultRequestHeaders.Authorization =
newAuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("OPTISWAY_API_KEY"));
var url = "https://optisway.com/api/v1/projects/42";
using var response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
var envelope = await response.Content.ReadFromJsonAsync<JsonElement>();
var error = envelope.GetProperty("error");
var message = envelope.GetProperty("message");
Console.Error.WriteLine($"{(int)response.StatusCode}{error}: {message}");
Environment.Exit(1);
}
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
Console.WriteLine($"ID: {body.GetProperty("id")}");
Console.WriteLine($"Name: {body.GetProperty("name")}");