Optisway ana sayfa
Dokümantasyon menüsü

REST API referansı: Projeler

Optisway’de bir proje, bir web sitesinin veya uygulamanın testlerini adresi ve açıklamasıyla bir araya getirir. Tek bir projeyle sınırlı bir anahtar yalnızca o projeyi görür; kapsamı olmayan bir anahtar organizasyonun tüm projelerini görür.

Project

Test sayısı ve en son çalıştırmasıyla bir proje.

Alanlar: Project
AlanTürAçıklama
idstringProjenin ondalık bir dize olarak kimliği.
namestringProjenin uygulamada gösterilen adı.
urlstringProjenin kapsadığı web sitesi adresi.
descriptionstringProjenin açıklaması; açıklama yazılmamışsa boş bir dize.
testCountintegerProjedeki test sayısı.
lastRunRunSummary | nullProjedeki herhangi bir testin en yeni çalıştırması (RunSummary) ya da ilk çalıştırmadan önce null.
createdAtISO 8601 stringProjenin oluşturulduğu zaman (UTC).
updatedAtISO 8601 stringProjenin son değiştirildiği zaman (UTC).
links.selfstringBu projenin yolu (GET /projects/{id}).
links.testsstringBu projenin testlerini listeleyen yol (GET /tests?project={id}).
Örnek: ProjectJSON
{
  "id": "42",
  "name": "Acme Shop",
  "url": "https://shop.example.com/",
  "description": "Storefront, checkout and account pages.",
  "testCount": 6,
  "lastRun": {
    "id": "4821",
    "status": "failed",
    "trigger": "api",
    "startedAt": "2026-10-19T09:12:01.000Z",
    "finishedAt": "2026-10-19T09:12:03.140Z",
    "durationMs": 2140,
    "summary": "503 Service Unavailable in 184 ms"
  },
  "createdAt": "2026-09-01T10:00:00.000Z",
  "updatedAt": "2026-10-12T08:41:00.000Z",
  "links": {
    "self": "/api/v1/projects/42",
    "tests": "/api/v1/tests?project=42"
  }
}

Projeleri listele GET /projects

Anahtarın kuruluşuna ait projeleri listeler; projeye bağlı bir anahtar yalnızca kendi projesini görür. read erişimi gerekir ve liste sayfalara bölünmez. Örnek, tek projesi (42) olan bir kuruluşu gösterir.

Gereken anahtar erişimi: Okuma

Parametreler

Bu uç nokta parametre almaz.

Örnek istek

curl --fail-with-body -sS "https://optisway.com/api/v1/projects" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/projects";
const response = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const { items } = await response.json();
for (const item of items) console.log(item.id, item.name);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.get(
    "https://optisway.com/api/v1/projects",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
for item in response.json()["items"]:
    print(item["id"], item["name"])
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/projects")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
JSON.parse(response.body)["items"].each do |item|
  puts [item["id"], item["name"]].join("  ")
end
<?php
$curl = curl_init("https://optisway.com/api/v1/projects");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
foreach (json_decode($body, true)["items"] as $item) {
  echo $item["id"], "  ", $item["name"], "\n";
}
// 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 class Main {
  public static void main(String[] args) throws Exception {
    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]any
	if 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`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("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")));
}

Örnek yanıt

Döndürür: items dizisinde Project nesneleri bulunan bir nesne.

Durum: 200 OK

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Yanıt gövdesi: Projeleri listeleJSON
{
  "items": [
    {
      "id": "42",
      "name": "Acme Shop",
      "url": "https://shop.example.com/",
      "description": "Storefront, checkout and account pages.",
      "testCount": 6,
      "lastRun": {
        "id": "4821",
        "status": "failed",
        "trigger": "api",
        "startedAt": "2026-10-19T09:12:01.000Z",
        "finishedAt": "2026-10-19T09:12:03.140Z",
        "durationMs": 2140,
        "summary": "503 Service Unavailable in 184 ms"
      },
      "createdAt": "2026-09-01T10:00:00.000Z",
      "updatedAt": "2026-10-12T08:41:00.000Z",
      "links": {
        "self": "/api/v1/projects/42",
        "tests": "/api/v1/tests?project=42"
      }
    }
  ]
}

Alabileceğiniz hatalar

  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.

Projeyi getir GET /projects/{id}

Bir projeyi sayısal kimliğiyle getirir. read erişimi gerekir; anahtarın kapsamı dışındaki bir proje, hiç var olmayan bir proje gibi 404 not_found yanıtı verir. Örnek, lastRun değeri başarısız çalıştırma 4821 olan 42 numaralı projeyi getirir.

Gereken anahtar erişimi: Okuma

Parametreler

Parametreler: GET /projects/{id}
AdKonumTürZorunluAçıklamaÖrnek
idYolstring (numeric project id)EvetProjenin Project.id alanında döndürülen sayısal kimliği.42

Örnek istek

curl --fail-with-body -sS "https://optisway.com/api/v1/projects/42" \
  -H "Authorization: Bearer $OPTISWAY_API_KEY"
// Node.js 18+: save as optisway.mjs and run `node optisway.mjs`
const url = "https://optisway.com/api/v1/projects/42";
const response = await fetch(url, {
  headers: {
    Authorization: `Bearer ${process.env.OPTISWAY_API_KEY}`,
  },
});
if (!response.ok) {
  const { error, message } = await response.json();
  console.error(`${response.status} ${error}: ${message}`);
  process.exit(1);
}
const body = await response.json();
console.log(`ID: ${body.id}`);
console.log(`Name: ${body.name}`);
# pip install requests
import os
import sys

import requests

api_key = os.environ["OPTISWAY_API_KEY"]
response = requests.get(
    "https://optisway.com/api/v1/projects/42",
    headers={"Authorization": f"Bearer {api_key}"},
    timeout=30,
)
if not response.ok:
    envelope = response.json()
    print(f"{response.status_code} {envelope['error']}: {envelope['message']}", file=sys.stderr)
    sys.exit(1)
body = response.json()
print("ID:", body["id"])
print("Name:", body["name"])
require "json"
require "net/http"
require "uri"

uri = URI("https://optisway.com/api/v1/projects/42")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("OPTISWAY_API_KEY")}"
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
unless response.is_a?(Net::HTTPSuccess)
  envelope = JSON.parse(response.body)
  warn "#{response.code} #{envelope["error"]}: #{envelope["message"]}"
  exit 1
end
body = JSON.parse(response.body)
puts "ID: #{body["id"]}"
puts "Name: #{body["name"]}"
<?php
$curl = curl_init("https://optisway.com/api/v1/projects/42");
curl_setopt_array($curl, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("OPTISWAY_API_KEY"),
  ],
]);
$body = curl_exec($curl);
if ($body === false) {
  fwrite(STDERR, curl_error($curl) . "\n");
  exit(1);
}
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  $envelope = json_decode($body, true);
  fwrite(STDERR, "$status {$envelope['error']}: {$envelope['message']}\n");
  exit(1);
}
$data = json_decode($body, true);
echo "ID: {$data['id']}\n";
echo "Name: {$data['name']}\n";
// 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 class Main {
  public static void main(String[] args) throws Exception {
    String url = "https://optisway.com/api/v1/projects/42";
    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);
    }
    String body = response.body();
    System.out.println("ID: " + field(body, "id"));
    System.out.println("Name: " + field(body, "name"));
  }

  /** 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/42"
	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]any
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		panic(err)
	}
	fmt.Println("ID:", body["id"])
	fmt.Println("Name:", body["name"])
}
// .NET 8: `dotnet new console`, replace Program.cs with this file, then `dotnet run`
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
  new AuthenticationHeaderValue("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")}");

Örnek yanıt

Döndürür: Bir Project nesnesi.

Durum: 200 OK

Başlıklar: Content-Type: application/json; charset=utf-8 Cache-Control: no-store

Yanıt gövdesi: Projeyi getirJSON
{
  "id": "42",
  "name": "Acme Shop",
  "url": "https://shop.example.com/",
  "description": "Storefront, checkout and account pages.",
  "testCount": 6,
  "lastRun": {
    "id": "4821",
    "status": "failed",
    "trigger": "api",
    "startedAt": "2026-10-19T09:12:01.000Z",
    "finishedAt": "2026-10-19T09:12:03.140Z",
    "durationMs": 2140,
    "summary": "503 Service Unavailable in 184 ms"
  },
  "createdAt": "2026-09-01T10:00:00.000Z",
  "updatedAt": "2026-10-12T08:41:00.000Z",
  "links": {
    "self": "/api/v1/projects/42",
    "tests": "/api/v1/tests?project=42"
  }
}

Alabileceğiniz hatalar

  • not_found 404 Kaynak yok veya anahtarın kapsamı dışında.
  • unauthorized 401 Anahtar eksik, hatalı biçimli, bilinmiyor, iptal edilmiş veya süresi dolmuş ya da onu oluşturan kişi artık üye değil.
  • rate_limited 429 Anahtar çok fazla istek gönderdi; Retry-After içindeki saniye kadar bekleyin.
  • unavailable 503 Bizim tarafımızda geçici bir sorun var; daha sonra tekrar deneyin.