### Consulta de Protocolo de Exclusão via GET Source: https://datajud-wiki.cnj.jus.br/para-tribunais/manutencao-datajud/servicos Permite consultar o status de um pedido de exclusão de processos enviado anteriormente via POST ou DELETE. Utiliza o método GET com o código de protocolo como parâmetro de caminho no endpoint /v1/processos/manutencao/lista-pedido/{protocolo}. A resposta é um JSON similar ao resultado do envio do pedido. ```http GET /v1/processos/manutencao/lista-pedido/TJPR86196DEL202212011669931750938 ``` ```json { "tribunal": "TJPR", "listaProcessos": [ "TJPR_202_G2_26818_00211340420198160000", "TJPR_202_G2_26812_00608409120198160000", "TJPR_198_G2_26830_00021310320198160117" ], "protocolo": "TJPR86196DEL202212011669931750938", "dataPedido": "1693411712918", "hash": "dd3a503eb13ef440d3da44b60e84fbc03fface2577a1946d428386e26d3c0441" } ``` -------------------------------- ### Search Judicial Process by Number using Postman, Python, and R Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo1 This snippet shows how to query the TRF1 court's public API to find a judicial process using its unique number. It requires an API Key for authorization and sends a JSON payload with the search query. The examples cover Postman for manual testing, Python using the requests library, and R using the httr library. ```Postman POST https://api-publica.datajud.cnj.jus.br/api_publica_trf1/_search Headers: Authorization: ApiKey [Chave Pública] Content-Type: application/json Body (raw): { "query": { "match": { "numeroProcesso": "00008323520184013202" } } } ``` ```Python import requests import json url = "https://api-publica.datajud.cnj.jus.br/api_publica_trf1/_search" payload = json.dumps({ "query": { "match": { "numeroProcesso": "00008323520184013202" } } }) #Substituir pela Chave Pública headers = { 'Authorization': 'ApiKey ', 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` ```R library(httr) #Substituir pela Chave Pública headers = c( 'Authorization' = 'ApiKey ', 'Content-Type' = 'application/json' ) body = '{ "query": { "match": { "numeroProcesso": "00008323520184013202" } } }'; res <- VERB("POST", url = "https://api-publica.datajud.cnj.jus.br/api_publica_trf1/_search", body = body, add_headers(headers)) cat(content(res, 'text')) ``` -------------------------------- ### Authentication - Basic Auth Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/envio-xml/autenticacao This section explains how to use Basic Authentication for API requests. It includes an example of how to format the Authorization header. ```APIDOC ## Basic Auth Authentication ### Description This endpoint uses Basic Authentication. You need to include the tribunal's username and password in the `Authorization` header of your HTTP request. The login and password will be provided by the CNJ. ### Method GET ### Endpoint `/v1/infra/versao` ### Parameters #### Header Parameters - **Authorization** (string) - Required - Contains the Basic Auth credentials in the format `Basic `. ### Request Example ``` GET https://datajud.stg.cloud.cnj.jus.br/modelo-de-transferencia-de-dados/v1/infra/versao HTTP/1.1 Accept-Encoding: gzip,deflate Authorization: Basic Host: wwwh.cnj.jus.br Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) ``` ### Response #### Success Response (200) - **version** (string) - The version of the service. - **status** (string) - The status of the service. #### Response Example ```json { "version": "1.0.0", "status": "UP" } ``` ``` -------------------------------- ### Kibana Dev Tools: Pagination Query (From/Size) Source: https://datajud-wiki.cnj.jus.br/para-tribunais/Datajud/Kibana Demonstrates how to implement pagination in Elasticsearch queries using the 'from' and 'size' parameters in Kibana's Dev Tools. This example retrieves 20 documents starting from the first result. ```json GET view-processos-sigilo-*/_search { "from": 0, "size": 20, "query": { "match": { "dadosBasicos.classeProcessual": 11551 } } } ``` -------------------------------- ### POST /api_publica_trf1/_search Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo1 Performs a search for a judicial process using its unique process number as a search parameter for the TRF1 tribunal. ```APIDOC ## POST /api_publica_trf1/_search ### Description Searches for a judicial process using its unique process number within the TRF1 tribunal. ### Method POST ### Endpoint https://api-publica.datajud.cnj.jus.br/api_publica_trf1/_search ### Parameters #### Headers - **Authorization** (string) - Required - APIKey [Public Key] - **Content-Type** (string) - Required - application/json #### Request Body - **query** (object) - Required - The search query object. - **match** (object) - Required - The match criteria. - **numeroProcesso** (string) - Required - The unique process number to search for. ### Request Example ```json { "query": { "match": { "numeroProcesso": "00008323520184013202" } } } ``` ### Response #### Success Response (200) - **[Response fields will vary based on search results]** (object) - Description of the process details. #### Response Example ```json { "took": 11, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 1.0, "hits": [ { "_index": "processo", "_type": "_doc", "_id": "00008323520184013202", "_score": 1.0, "_source": { "numeroProcesso": "00008323520184013202", "dataDistribuicao": "2018-01-01", "orgaoJulgador": { "codigo": 1, "descricao": "1ª VARA FEDERAL DE CACHOEIRA ALTA-GO" } } } ] } } ``` ``` -------------------------------- ### Search Cases by Class and Judging Body using Postman, Python, and R Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo2 This snippet demonstrates how to query the DataJud API to find cases matching a specific 'Classe Processual' (1116 - Execução Fiscal) and 'Órgão Julgador' (13597 - VARA DE EXECUÇÃO FISCAL DO DF) for the TJDFT. It requires an API key for authorization. The examples cover using Postman for manual requests, Python with the 'requests' library, and R with the 'httr' library to send POST requests with a JSON body. ```json { "query": { "bool": { "must": [ {"match": {"classe.codigo": 1116}}, {"match": {"orgaoJulgador.codigo": 13597}} ] } } } ``` ```python import requests import json url = "https://api-publica.datajud.cnj.jus.br/api_publica_tjdft/_search" payload = json.dumps({ "query": { "bool": { "must": [ {"match": {"classe.codigo": 1116}}, {"match": {"orgaoJulgador.codigo": 13597}} ] } } } ) #Substituir pela Chave Pública headers = { 'Authorization': 'ApiKey ', 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text) ``` ```r library(httr) #Substituir pela Chave Pública headers = c( 'Authorization' = 'ApiKey ', 'Content-Type' = 'application/json' ) body = '{ "query": { "bool": { "must": [ {"match": {"classe.codigo": 1116}}, {"match": {"orgaoJulgador.codigo": 13597}} ] } } }'; res <- VERB("POST", url = "https://api-publica.datajud.cnj.jus.br/api_publica_tjdft/_search", body = body, add_headers(headers)) cat(content(res, 'text')) ``` -------------------------------- ### Exemplo de Requisição HTTP com Basic Auth Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/envio-xml/autenticacao Este exemplo demonstra como realizar uma requisição GET para o endpoint Valdiar Serviço com autenticação Basic Auth. O cabeçalho Authorization deve conter o hash de autenticação fornecido pelo CNJ. Certifique-se de que o host e outros cabeçalhos estejam configurados corretamente. ```http GET https://datajud.stg.cloud.cnj.jus.br/modelo-de-transferencia-de-dados/v1/infra/versao HTTP/1.1 Accept-Encoding: gzip,deflate Authorization: Basic Host: wwwh.cnj.jus.br Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5) ``` -------------------------------- ### Search by Processual Class and Judging Body Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo2 This endpoint allows you to search for processes based on a specific 'Classe Processual' (Processual Class) and 'Orgao Julgador' (Judging Body). The example demonstrates searching for processes with Class Code 1116 ('Execução Fiscal') and Judging Body Code 13597 ('VARA DE EXECUÇÃO FISCAL DO DF') in the TJDFT tribunal. ```APIDOC ## POST /api_publica_tribunal/_search ### Description Allows searching for processes based on Processual Class and Judging Body codes. ### Method POST ### Endpoint https://api-publica.datajud.cnj.jus.br/api_publica_tjdft/_search ### Parameters #### Headers - **Authorization** (string) - Required - The API key for authentication. Format: 'ApiKey [Chave Pública]'. - **Content-Type** (string) - Required - The content type of the request body. Value: 'application/json'. #### Request Body - **query** (object) - Required - The search query object. - **bool** (object) - Required - Boolean logic for the query. - **must** (array) - Required - An array of conditions that must all be met. - **match** (object) - Required - Specifies a field and value to match. - **classe.codigo** (integer) - Required - The code for the Processual Class. - **orgaoJulgador.codigo** (integer) - Required - The code for the Judging Body. ### Request Example ```json { "query": { "bool": { "must": [ {"match": {"classe.codigo": 1116}}, {"match": {"orgaoJulgador.codigo": 13597}} ] } } } ``` ### Response #### Success Response (200) - **response.text** (string) - The search results in JSON format. ``` -------------------------------- ### GET /v1/infra/versao Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/envio-xml/exemplos/validando-servico Endpoint para verificar se a API de recebimento do Datajud está no ar e se a autenticação do Tribunal é bem sucedida. O login e senha de acesso à API são informados pelo CNJ. ```APIDOC ## GET /v1/infra/versao ### Description Verifica a disponibilidade da API de recebimento do Datajud e o sucesso da autenticação do Tribunal. ### Method GET ### Endpoint /v1/infra/versao ### Parameters #### Path Parameters Nenhum. #### Query Parameters Nenhum. #### Request Body Nenhum. ### Request Example **Curl:** ```bash curl --location 'https://datajud.stg.cloud.cnj.jus.br/modelo-de-transferencia-de-dados/v1/infra/versao' \ --header 'Authorization: Basic ' \ --header 'Cookie: INGRESSCOOKIE=a2c0797e0eb379b4733eb9' ``` **Python:** ```python import requests url = "https://datajud.stg.cloud.cnj.jus.br/modelo-de-transferencia-de-dados/v1/infra/versao" payload = {} headers = { 'Authorization': 'Basic ', 'Cookie': 'INGRESSCOOKIE=a2c0797e0eb379b4733eb9fe6a99df21|1aea6caa1fbc0b9eaa6190c02b0d3137' } response = requests.request("GET", url, headers=headers, data=payload) print(response.text) ``` ### Response #### Success Response (200) Retorna um JSON indicando o status de sucesso e a versão atual da API. - **status** (string) - Indica o status da operação ('SUCESSO'). - **mensagem** (string) - Informa a versão atual da API ('Versão: 1.0.1.1 (PROD)'). #### Response Example ```json { "status": "SUCESSO", "mensagem": "Versão: 1.0.1.1 (PROD)" } ``` ``` -------------------------------- ### Datajud API - Initial Search with Sorting Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo3 This example shows the initial DSL query to perform a search and enable pagination by sorting on the '@timestamp' field. The 'size' parameter controls the number of records per page. ```APIDOC ## POST /search ### Description Performs a search with sorting enabled to facilitate pagination. Returns up to 10,000 records per page. ### Method POST ### Endpoint /search ### Parameters #### Query Parameters - **size** (integer) - Optional - The number of records to return per page (10-10000). #### Request Body - **query** (object) - Required - The Elasticsearch query DSL. - **bool** (object) - Required - Combines multiple query clauses. - **must** (array) - Required - Clauses that must all match. - **match** (object) - Required - Performs a full-text search. - **classe.codigo** (integer) - Required - The code for the class. - **orgaoJulgador.codigo** (integer) - Required - The code for the judging body. - **sort** (array) - Required - Specifies the order of the results. - **@timestamp** (object) - Required - Sort by the timestamp field. - **order** (string) - Required - The sort order, either 'asc' or 'desc'. ### Request Example ```json { "size": 100, "query": { "bool": { "must": [ {"match": {"classe.codigo": 1116}}, {"match": {"orgaoJulgador.codigo": 13597}} ] } }, "sort": [ { "@timestamp": { "order": "asc" } } ] } ``` ### Response #### Success Response (200) - **_index** (string) - The index name. - **_type** (string) - The document type. - **_id** (string) - The document ID. - **_source** (object) - The source document. - **sort** (array) - An array containing the sort values for the document, used for subsequent pagination. #### Response Example ```json { "_index" : "api_publica_tjdft", "_type" : "_doc", "_id" : "TJDFT_1116_G1_13597_00356079220168070018", "_score" : null, "_source" : { ... }, "sort" : [ 1681366085550 ] } ``` ``` -------------------------------- ### GET /view-processos-sigilo-*/_search - Utilização de Wildcard (Like) em Partes Source: https://datajud-wiki.cnj.jus.br/para-tribunais/Datajud/Kibana Searches for processes where a party's name contains a specified wildcard string. ```APIDOC ## GET /view-processos-sigilo-*/_search ### Description Searches for processes where a party's name contains a specified wildcard string. This endpoint uses nested wildcards to search within the party information. ### Method GET ### Endpoint /view-processos-sigilo-*/_search ### Query Parameters None ### Request Body ```json { "query": { "nested": { "path": "dadosBasicos.polo", "query": { "nested": { "path": "dadosBasicos.polo.parte", "query": { "wildcard": { "dadosBasicos.polo.parte.pessoa.nome": "*INSS*" } } } } } } } ``` ### Request Example ```json { "query": { "nested": { "path": "dadosBasicos.polo", "query": { "nested": { "path": "dadosBasicos.polo.parte", "query": { "wildcard": { "dadosBasicos.polo.parte.pessoa.nome": "*INSS*" } } } } } } } ``` ### Response #### Success Response (200) - **_index** (string) - The index of the document. - **_type** (string) - The type of the document. - **_id** (string) - The ID of the document. - **_score** (float) - The relevance score of the document. - **_source** (object) - The source fields of the document. #### Response Example ```json { "took": 20, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 5, "relation": "eq" }, "max_score": 2.5, "hits": [ { "_index": "view-processos-sigilo-2023.09.21", "_type": "_doc", "_id": "processo456", "_score": 2.5, "_source": { "dadosBasicos": { "polo": { "parte": { "pessoa": { "nome": "INSTITUTO NACIONAL DO SEGURO SOCIAL - INSS" } } } } } } ] } } ``` ``` -------------------------------- ### JSON Response Structure for Process Metadata Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo1 This JSON structure represents the expected output when querying for process metadata. It includes search result statistics, shard information, and detailed hit data for one or more legal processes. The 'hits.hits._source' object contains the core process metadata, such as case number, class, system, tribunal, timestamps, movements, and judicial organ information. ```json { "took": 6679, "timed_out": false, "_shards": { "total": 7, "successful": 7, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 13.917725, "hits": [ { "_index": "api_publica_trf1", "_type": "_doc", "_id": "TRF1_436_JE_16403_00008323520184013202", "_score": 13.917725, "_source": { "numeroProcesso": "00008323520184013202", "classe": { "codigo": 436, "nome": "Procedimento do Juizado Especial Cível" }, "sistema": { "codigo": 1, "nome": "Pje" }, "formato": { "codigo": 1, "nome": "Eletrônico" }, "tribunal": "TRF1", "dataHoraUltimaAtualizacao": "2023-07-21T19:10:08.483Z", "grau": "JE", "@timestamp": "2023-08-14T11:50:51.994Z", "dataAjuizamento": "2018-10-29T00:00:00.000Z", "movimentos": [ { "complementosTabelados": [ { "codigo": 2, "valor": 1, "nome": "competência exclusiva", "descricao": "tipo_de_distribuicao_redistribuicao" } ], "codigo": 26, "nome": "Distribuição", "dataHora": "2018-10-30T14:06:24.000Z" }, { "codigo": 14732, "nome": "Conversão de Autos Físicos em Eletrônicos", "dataHora": "2020-08-05T01:15:18.000Z" } ], "id": "TRF1_436_JE_16403_00008323520184013202", "nivelSigilo": 0, "orgaoJulgador": { "codigoMunicipioIBGE": 5128, "codigo": 16403, "nome": "JEF Adj - Tefé" }, "assuntos": [ { "codigo": 6177, "nome": "Concessão" } ] } } ] } } ``` -------------------------------- ### Consultar status de pedido de exclusão Source: https://datajud-wiki.cnj.jus.br/para-tribunais/manutencao-datajud/contrato Utiliza o endpoint GET /v1/processos/manutencao/lista-pedido/{protocolo} para consultar o status de um pedido de remoção de chaves no Datajud, utilizando o protocolo do pedido. A autenticação é feita via HTTP Basic Authentication. ```http GET /v1/processos/manutencao/lista-pedido/12345 HTTP/1.1 Host: seu-host.com Authorization: Basic SE9UVEVMOlBBU1NXT1JE ``` -------------------------------- ### JSON Process Metadata Response Structure Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo2 This JSON structure represents the expected output for a search query, containing metadata for one or more legal processes. It includes details about the search took time, shard information, and a list of 'hits' where each hit details a specific legal process. ```json { "took": 213, "timed_out": false, "_shards": { "total": 3, "successful": 3, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 10000, "relation": "gte" }, "max_score": 2.0, "hits": [ { "_index": "api_publica_tjdft", "_type": "_doc", "_id": "TJDFT_1116_G1_13597_07223914020178070001", "_score": 2.0, "_source": { "classe": { "codigo": 1116, "nome": "Execução Fiscal" }, "numeroProcesso": "07223914020178070001", "sistema": { "codigo": 1, "nome": "Pje" }, "formato": { "codigo": 1, "nome": "Eletrônico" }, "tribunal": "TJDFT", "dataHoraUltimaAtualizacao": "2022-09-06T12:03:20.257Z", "grau": "G1", "@timestamp": "2023-04-13T17:59:46.214Z", "dataAjuizamento": "2017-08-21T10:05:32.000Z", "movimentos": [ { "complementosTabelados": [ { "codigo": 2, "valor": 2, "nome": "sorteio", "descricao": "tipo_de_distribuicao_redistribuicao" } ], "codigo": 26, "nome": "Distribuição", "dataHora": "2017-08-21T10:05:32.000Z" }, { "codigo": 11382, "nome": "Bloqueio/penhora on line", "dataHora": "2022-07-13T07:25:59.000Z" }, { "codigo": 132, "nome": "Recebimento", "dataHora": "2022-07-13T07:26:00.000Z" } ], "id": "TJDFT_1116_G1_13597_07223914020178070001", "nivelSigilo": 0, "orgaoJulgador": { "codigoMunicipioIBGE": 5300108, "codigo": 13597, "nome": "VARA DE EXECU??O FISCAL DO DF" }, "assuntos": [ [ { "codigo": 6017, "nome": "Dívida Ativa (Execução Fiscal)" } ] ] } }, { "_index": "api_publica_tjdft", "_type": "_doc", "_id": "TJDFT_1116_G1_13597_00073039720138070015", "_score": 2.0, "_source": { "classe": { "codigo": 1116, "nome": "Execução Fiscal" }, "numeroProcesso": "00073039720138070015", "sistema": { "codigo": 1, "nome": "Pje" }, "formato": { "codigo": 1, "nome": "Eletrônico" }, "tribunal": "TJDFT", "dataHoraUltimaAtualizacao": "2022-09-06T17:26:23.938Z", "grau": "G1", "@timestamp": "2023-04-13T18:02:23.754Z", "dataAjuizamento": "2019-05-30T03:17:56.000Z", "movimentos": [ { "complementosTabelados": [ { "codigo": 2, "valor": 1, "nome": "competência exclusiva", "descricao": "tipo_de_distribuicao_redistribuicao" } ], "codigo": 26, "nome": "Distribuição" } ] } } ] } } ``` -------------------------------- ### Estrutura XML Básica Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/criacao-arquivo/exemplo-xml Este é um exemplo simples de um arquivo XML que demonstra elementos aninhados e atributos. Arquivos XML são frequentemente usados para armazenar e transportar dados de forma legível por humanos e máquinas. ```xml Some text content More data ``` -------------------------------- ### Elasticsearch Datamart Tag Example Source: https://datajud-wiki.cnj.jus.br/para-tribunais/Datajud/tag-datamart An example of a datamart tag generated by Elasticsearch after processing statistical data. It includes metadata such as Datamart ID, Current Situation, Current Phase, Discharge Date, New Case Date, and Criminal Flag. ```json { "datamart" : { "@timestamp" : "2024-11-09T18:07:40.192489", "updated_at" : "2024-11-09T04:33:14.118380", "id_situacao_atual" : 10, "id" : 639186446, "situacao_atual" : "Baixado definitivamente", "id_fase_atual" : 4, "fase_atual" : "OUTRO", "data_cn" : "2005-04-28T00:00:00", "data_situacao_atual" : "2024-04-03T11:33:46", "criminal" : false, "data_baixa" : "2011-01-10T00:00:00" } } ``` -------------------------------- ### Exemplo de Processo Judicial em XML (MTD 1.2) Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/criacao-arquivo/exemplo-xml Este snippet XML demonstra a estrutura de um processo judicial conforme o padrão MTD 1.2. Ele inclui detalhes como dados básicos do processo, informações das partes (físicas e jurídicas), advogados, assuntos, vínculos com outros processos, movimentações e decisões. ```xml Avenida Afonso Pena 3297 Centro Campo Grande MS BR Rua Saint Romain 1524 Jardim Tijuca Campo Grande 5002704 MS BR Rua Alcebíades Barbosa 1147 Nova Lima Campo Grande MS BR ID 20150826 6017 TJMS G2 true ID DG 1525.91 38.40 2025.05.000123-4 – 3ª DP – PC/MS 2025/00056789 – Delegacia Virtual – PC/MS 0001234-89.2025.8.12.0001 005678/2024 – DPC/DOURADOS – PC/MS 00842355430 Documento ``` -------------------------------- ### JSON Data Structure Example for Judicial Cases Source: https://datajud-wiki.cnj.jus.br/api-publica/exemplos/exemplo2 This snippet demonstrates a typical JSON structure for representing judicial case information. It includes fields for case identifiers, parties involved, legal subjects, and timestamps. The data is organized hierarchically, allowing for detailed case information retrieval. ```json { "dataHora": "2013-02-18T13:17:23.000Z" } { "codigo": 245, "nome": "Provisório", "dataHora": "2019-05-30T11:10:02.000Z" } { "codigoMunicipioIBGE": 5300108, "codigo": 13597, "nome": "VARA DE EXECU??O FISCAL DO DF" } { "codigo": 6017, "nome": "Dívida Ativa (Execução Fiscal)" } { "codigo": 10394, "nome": "Dívida Ativa não-tributária" } { "id": "TJDFT_1116_G1_13597_00073039720138070015", "nivelSigilo": 0, "orgaoJulgador": { "codigoMunicipioIBGE": 5300108, "codigo": 13597, "nome": "VARA DE EXECU??O FISCAL DO DF" }, "assuntos": [ [ { "codigo": 6017, "nome": "Dívida Ativa (Execução Fiscal)" } ], [ { "codigo": 10394, "nome": "Dívida Ativa não-tributária" } ] ] } ``` -------------------------------- ### Simular envio de XML (G2) via Python Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/verificacao/Simulando%20Envio Exemplo de como simular o envio de um arquivo XML para o endpoint G2 do Datajud utilizando a biblioteca requests em Python. É necessário definir a URL do endpoint, o caminho do arquivo XML, e incluir o cookie de autenticação nos headers da requisição. ```python import requests url = "https://validador.stg.cloud.cnj.jus.br/v1/processos/G2" # Nome e caminho do arquivo XML # No exemplo abaixo o arquivo está no mesmo diretório do script arquivo = "processos.xml" payload = {} files=[("arquivo",("processos.xml",open(arquivo,"rb"),"text/xml"))] headers = {"Cookie": "INGRESSCOOKIE=2fe5f2fe04b95b"} response = requests.request("POST", url, headers=headers, data=payload, files=files) print(response.text) ``` -------------------------------- ### Exemplo de Resposta de Sucesso do Envio - JSON Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/envio-xml/envio-rest Exemplo de resposta JSON esperada quando o envio de processos é executado com sucesso e sem erros. Inclui o status da operação e um número de protocolo. ```json { "status": "SUCESSO", "protocolo": "SIGLATRIBUNALXXXXXXXXXXXXXXXXXXXXXXXXXXX" } ``` -------------------------------- ### Enviar Arquivo ZIP ao Datajud (Python) Source: https://datajud-wiki.cnj.jus.br/para-tribunais/orientacoes-rest/envio-xml/exemplos/envio-processo Utiliza a biblioteca requests em Python para enviar um arquivo ZIP de processos judiciais. Configura a URL, payload com o conteúdo do arquivo ZIP e os cabeçalhos HTTP, incluindo 'Content-Type' como 'multipart/form-data' e o boundary específico. A resposta da API é impressa. ```python import requests url = "https://datajud.stg.cloud.cnj.jus.br/modelo-de-transferencia-de-dados/v1/processos/G2" payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"arquivo\"; filename=\"C:/arquivos-xml/processos.xml.zip\"\r\nContent-Type: application/zip\r\n\r\n\r\n-----011000010111000001101001--\r\n" headers = { "cookie": "INGRESSCOOKIE=a2c0797e0eb379b4733eb9", "Content-Type": "multipart/form-data; boundary=---011000010111000001101001", "Authorization": "Basic " } response = requests.request("POST", url, data=payload, headers=headers) print(response.text) ``` -------------------------------- ### GET /view-processos-sigilo-*/_search - Partes tipoPessoa = "FISICA" sem numeroDocumentoPrincipal Source: https://datajud-wiki.cnj.jus.br/para-tribunais/Datajud/Kibana Filters processes to find parties of type 'FISICA' that do not have a 'numeroDocumentoPrincipal'. ```APIDOC ## GET /view-processos-sigilo-*/_search ### Description Filters processes to find parties of type 'FISICA' that do not have a 'numeroDocumentoPrincipal'. This uses nested filtering to ensure accuracy. ### Method GET ### Endpoint /view-processos-sigilo-*/_search ### Query Parameters - **size** (integer) - Optional - The maximum number of results to return. Defaults to 2 in the example. ### Request Body ```json { "size": 2, "query": { "bool": { "filter": [ { "nested": { "path": "dadosBasicos.polo.parte", "query": { "bool": { "must": [ { "match": { "dadosBasicos.polo.parte.pessoa.tipoPessoa": "FISICA" } } ], "must_not": [ { "exists": { "field": "dadosBasicos.polo.parte.pessoa.numeroDocumentoPrincipal" } } ] } } } } ] } } } ``` ### Request Example ```json { "size": 2, "query": { "bool": { "filter": [ { "nested": { "path": "dadosBasicos.polo.parte", "query": { "bool": { "must": [ { "match": { "dadosBasicos.polo.parte.pessoa.tipoPessoa": "FISICA" } } ], "must_not": [ { "exists": { "field": "dadosBasicos.polo.parte.pessoa.numeroDocumentoPrincipal" } } ] } } } } ] } } } ``` ### Response #### Success Response (200) - **_index** (string) - The index of the document. - **_type** (string) - The type of the document. - **_id** (string) - The ID of the document. - **_score** (float) - The relevance score of the document. - **_source** (object) - The source fields of the document. #### Response Example ```json { "took": 30, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 3, "relation": "eq" }, "max_score": 1.0, "hits": [ { "_index": "view-processos-sigilo-2023.09.21", "_type": "_doc", "_id": "processo789", "_score": 1.0, "_source": { "dadosBasicos": { "polo": { "parte": { "pessoa": { "tipoPessoa": "FISICA" } } } } } } ] } } ``` ```