# Quick Start

As a quick start, let's get you your registration file. U just need two steps:

1. Send a login request
2. Send a registration file request

{% hint style="info" %}
The simpler way to do API requests is using a web API tester, I recommend [Insomnia](https://insomnia.rest/).
{% endhint %}

## 1. Send a login request

The easiest way to log in is by sending a <mark style="color:green;">POST</mark> request to the `/login` end-point, this end-point requires a body with just two pieces of information:

1. `cpf` Your CPF numbers as u type on [Siga 3](https://docs.laravieira.me/mysiga/siga-3)
2. `password` Your password as u type on [Siga 3](https://docs.laravieira.me/mysiga/siga-3)

{% hint style="info" %}
If you are afraid of your password being stolen by a [malicious proxy](https://www.techtarget.com/searchitchannel/definition/proxy-hacking) or by MySiga server, you can do a <mark style="color:green;">POST</mark> request to the end-point `/login/raw` where you will need to encrypt your password before sending it, as it adds a lot of complexity it will not be covered in this quick tutorial.
{% endhint %}

With your CPF and password ready, u can prepare and send the login request like so:

{% tabs %}
{% tab title="cURL" %}

```sh
curl --request POST \
  --url https://mysiga.laravieira.me/login \
  --header 'Content-Type: multipart/form-data' \
  --form cpf=12345678901 \
  --form password=mysiga123
```

{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$cpf = '12345678901';
$password = 'mysiga123';

$headers = array("Content-Type: application/x-www-form-urlencoded");
$data = "cpf=$cpf&password=$password";

$curl = curl_init("https://mysiga.laravieira.me/login");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
from requests.structures import CaseInsensitiveDict

url = "https://mysiga.laravieira.me/login"

headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/x-www-form-urlencoded"

data = "cpf=12345678901&password=mysiga123"

response = requests.post(url, headers=headers, data=data)
```

{% endcode %}
{% endtab %}
{% endtabs %}

If everything worked, you should get a JSON response like this:

{% code lineNumbers="true" %}

```json
{
	"server": "https:\/\/sigam1.ufjf.br\/index.php",
	"siga": "cltrava6630eo6fln4ao621vn2",
	"client": "1e1a3a2698a6ac2fb0bbe8867f713e09",
	"logged": true
}
```

{% endcode %}

## 2. Send a registration file request

Now you're logged, so let's do a <mark style="color:green;">GET</mark> request to `/academic/registration/browser` end-point, this only requires the `PHPSESSID` cookie to be sent so it knows who u are, the `PHPSESSID` value is the same as the `"client"` field on the login response.

{% tabs %}
{% tab title="cURL" %}

```sh
curl --request GET \
  --url https://mysiga.laravieira.me/academic/registration/browser \
  --cookie 'PHPSESSID=1e1a3a2698a6ac2fb0bbe8867f713e09'
```

{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$headers = array(
    'Cookie: PHPSESSID=1e1a3a2698a6ac2fb0bbe8867f713e09'
);

$curl= curl_init('https://mysiga.laravieira.me/academic/registration/browser');
curl_setopt($curl, CURLOPT_HTTPHEADER,     $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_exec($curl);
curl_close($curl);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
from requests.structures import CaseInsensitiveDict

headers = CaseInsensitiveDict()
headers["Cookie"] = "PHPSESSID=1e1a3a2698a6ac2fb0bbe8867f713e09"

requests.get("https://mysiga.laravieira.me/academic/registration/browser", headers=headers)
```

{% endcode %}
{% endtab %}
{% endtabs %}

If you are using the browser or an API tester, the registration pdf will show up.

{% hint style="info" %}
If you are not using a browser or an API tester, you may see the raw pdf data of the registration file, you can save this data to a file, set the extension of that file to .pdf, and then open it normally.
{% endhint %}

## Extra step

If you are a person who loves to click on the logout button, u can also send a <mark style="color:green;">GET</mark> request to `/login/logout` destroy your session on the MySiga and on [Siga 3](https://docs.laravieira.me/mysiga/siga-3). This also requires u to send the `PHPSESSID`, so MySiga knows which session to destroy. Do it like this:

{% tabs %}
{% tab title="cURL" %}

```sh
curl --request GET \
  --url https://mysiga.laravieira.me/login/logout \
  --cookie 'PHPSESSID=1e1a3a2698a6ac2fb0bbe8867f713e09'
```

{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$headers = array(
    'Cookie: PHPSESSID=1e1a3a2698a6ac2fb0bbe8867f713e09'
);

$curl= curl_init('https://mysiga.laravieira.me/login/logout');
curl_setopt($curl, CURLOPT_HTTPHEADER,     $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_exec($curl);
curl_close($curl);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
import requests
from requests.structures import CaseInsensitiveDict

headers = CaseInsensitiveDict()
headers["Cookie"] = "PHPSESSID=1e1a3a2698a6ac2fb0bbe8867f713e09"

requests.get("https://mysiga.laravieira.me/login/logout", headers=headers)
```

{% endcode %}
{% endtab %}
{% endtabs %}

The logout will give u a JSON response like that:

{% code lineNumbers="true" %}

```json
{
	"server": "https:\/\/sigam1.ufjf.br\/index.php",
	"siga": "cltrava6630eo6fln4ao621vn2",
	"client": null,
	"logged": false
}
```

{% endcode %}

## Next steps

Now that u had accomplished the Quick Start tutorial, feel free to check out the reference and discover more about MySiga API.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.laravieira.me/mysiga/quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
