Sessões
POST /api/session
Inicia nova sessão de circuito e devolve identificador.
Exemplo
cURL
PowerShell
Copiar
curl -X POST \
-H "Content-Type: application/json" \
http://fizicar.somee.com/api/session
Copiar
Invoke-RestMethod -Method POST `
-Uri 'http://fizicar.somee.com/api/session' `
-ContentType 'application/json' `
-Body '{}'
Resposta 200
{ "sessionId": "abc-123" }
Componentes
POST /api/{sessionId}/component
Adiciona um novo componente ao circuito da sessão.
Pedido
{
"id": "R1",
"type": "resistor",
"value": 1000
}
Exemplo
cURL
PowerShell
Copiar
curl -X POST \
-H "Content-Type: application/json" \
-d '{"id":"R1","type":"resistor","value":1000}' \
http://fizicar.somee.com/api/abc-123/component
Copiar
Invoke-RestMethod -Method POST `
-Uri 'http://fizicar.somee.com/api/abc-123/component' `
-ContentType 'application/json' `
-Body '{"id":"R1","type":"resistor","value":1000}'
Resposta 201
{
"id": "R1",
"type": "resistor",
"value": 1000,
"nodeA": "n1",
"nodeB": "n2"
}
Ligações
POST /api/{sessionId}/connect
Cria uma ligação entre terminais de dois componentes.
Pedido
{
"component1": "R1",
"terminal1": "a",
"component2": "V1",
"terminal2": "a"
}
Exemplo
cURL
PowerShell
Copiar
curl -X POST \
-H "Content-Type: application/json" \
-d '{"component1":"R1","terminal1":"a","component2":"V1","terminal2":"a"}' \
http://fizicar.somee.com/api/abc-123/connect
Copiar
Invoke-RestMethod -Method POST `
-Uri 'http://fizicar.somee.com/api/abc-123/connect' `
-ContentType 'application/json' `
-Body '{"component1":"R1","terminal1":"a","component2":"V1","terminal2":"a"}'
Resposta 200
{ "message": "Connection added" }
Circuito
POST /api/{sessionId}/circuit
Monta o circuito com listas completas de componentes e ligações.
Pedido
{
"components": [
{ "id": "V1", "type": "voltageSource", "value": 5 },
{ "id": "R1", "type": "resistor", "value": 1000 }
],
"connections": [
{ "component1": "V1", "terminal1": "a", "component2": "R1", "terminal2": "a" }
]
}
Exemplo
cURL
PowerShell
Copiar
curl -X POST \
-H "Content-Type: application/json" \
-d '{"components":[{"id":"V1","type":"voltageSource","value":5},{"id":"R1","type":"resistor","value":1000}],
"connections":[{"component1":"V1","terminal1":"a","component2":"R1","terminal2":"a"}]}' \
http://fizicar.somee.com/api/abc-123/circuit
Copiar
Invoke-RestMethod -Method POST `
-Uri 'http://fizicar.somee.com/api/abc-123/circuit' `
-ContentType 'application/json' `
-Body '{
"components":[{"id":"V1","type":"voltageSource","value":5},{"id":"R1","type":"resistor","value":1000}],
"connections":[{"component1":"V1","terminal1":"a","component2":"R1","terminal2":"a"}]
}'
Resposta 200
{ "message": "Circuit built" }
Circuito
GET /api/{sessionId}/circuit
Devolve a estrutura actual de componentes e ligações da sessão.
Exemplo
cURL
PowerShell
Copiar
curl -X GET \
http://fizicar.somee.com/api/abc-123/circuit
Copiar
Invoke-RestMethod -Method GET `
-Uri 'http://fizicar.somee.com/api/abc-123/circuit'
Resposta 200
{
"components": [
{ "id": "V1", "type": "voltageSource", "value": 5, "nodeA": "0", "nodeB": "1" },
{ "id": "R1", "type": "resistor", "value": 1000, "nodeA": "1", "nodeB": "0" }
],
"connections": [
{ "component1": "V1", "terminal1": "a", "component2": "R1", "terminal2": "a" }
]
}
Análise
GET /api/{sessionId}/analysis
Executa análise eléctrica e devolve tensão e corrente por componente.
Exemplo
cURL
PowerShell
Copiar
curl -X GET \
http://fizicar.somee.com/api/abc-123/analysis
Copiar
Invoke-RestMethod -Method GET `
-Uri 'http://fizicar.somee.com/api/abc-123/analysis'
Resposta 200
{
"componentResults": [
{ "id": "V1", "voltage": 5, "current": 0.005 },
{ "id": "R1", "voltage": 5, "current": 0.005 }
]
}