Tenho um código que faz a comunicação com os cards do pipefy, porém não estou conseguindo interpretar os dados, vou mandar o código para entenderem e o resultado, porém, basicamente o que eu preciso é mandar isso para um DataFrame.. -- coding: utf-8 -- import json import pandas as pd import requests from requests.auth import HTTPBasicAuth import gspread from oauth2client.service_account import ServiceAccountCredentials from df2gspread import df2gspread as d2g import os import time from datetime import datetime import collections from urllib.request import urlopen from pandas.io.json import json_normalize #{ # allCards(pipeId: 178186, first: 50, after:"WyI5LjUiLCIxNjMyLjAiLDI5MjQ2MDg5XQ==") { # pageInfo { # endCursor # hasNextPage # } # edges { # node { # id # title # fields { # value # } # assignees { # } # phases_history { # duration # firstTimeIn # created_at # phase { # name # } # } # } # } # } #} url = "https://api.pipefy.com/graphql" payload = "{\"query\":\"{ allCards(pipeId:178186, first: 50, after:\\"xxxxxxxxxxxxxxx\\"){ pageInfo{ endCursor hasNextPage } edges{ node{ id title fields{ value } assignees{ email } phases_history{ duration firstTimeIn created_at phase{ name } } } } } }\"}" headers = { 'authorization': "Bearer xxxxxxx......", 'content-type': "application/json" } response = requests.request("POST", url, data=payload, headers=headers) Pega todo o conteúdo disponibilizado no código a cima e joga dentro da variável dadosUrl em formato TEXT dadosUrl = json.loads(response.text) print(response.text) RESULTADO: {"data":{"allCards":{"edges":v{"node":{"assignees":o],"fields": {"value":"Bloco Foto ar \n\nAd 100 / 10pares \nAd 125/ 10pares \nAd 150/10 pares \nAd175 /10pares \nAd200/10pares\nAd225/10pares\nAd250/10pares\nAd 300/10pares"},{"value":"SEMIR"},{"value":"29.930.391/0001-25"},{"value":"3x"},{"value":"Analise de credito"},{"value":"FABIO PEREIRA AMERICO"},{"value":"1014"},{"value":"21/05/2019"},{"value":"Sim"},{"value":"5755"},{"value":"320 BLOCOS "},{"value":"14/05/2019"},{"value":"5590"},{"value":"Reprovada"},{"value":"Sim"}],"id":"28947871","phases_history":0{"created_at":"2019-05-14T17:20:27-03:00","duration":0,"firstTimeIn":"2019-05-14T20:20:27+00:00","phase":{"name":"Start form"}},{"created_at":"2019-05-14T17:20:27-03:00","duration":4,"firstTimeIn":"2019-05-14T20:20:27+00:00","phase":{"name":"Solicitação"}},{"created_at":"2019-05-14T17:20:32-03:00","duration":1606,"firstTimeIn":"2019-05-14T20:20:32+00:00","phase":{"name":"Digitação"}},{"created_at":"2019-05-14T17:47:19-03:00","duration":52061,"firstTimeIn":"2019-05-14T20:47:19+00:00","phase":{"name":"Analise de Crédito"}},{"created_at":"2019-05-15T08:15:00-03:00","duration":453500,"firstTimeIn":"2019-05-15T11:15:00+00:00","phase":{"name":"Bloqueado "}},{"created_at":"2019-05-20T14:13:20-03:00","duration":71306,"firstTimeIn":"2019-05-20T17:13:21+00:00","phase":{"name":"Liberado p/ Separação"}},{"created_at":"2019-05-21T10:01:47-03:00","duration":1433,"firstTimeIn":"2019-05-21T13:01:47+00:00","phase":{"name":"Separação"}},{"created_at":"2019-05-21T10:25:40-03:00","duration":5059,"firstTimeIn":"2019-05-21T13:25:40+00:00","phase":{"name":"Conferência"}},{"created_at":"2019-05-21T11:49:59-03:00","duration":311,"firstTimeIn":"2019-05-21T14:49:59+00:00","phase":{"name":"Embalagem"}},{"created_at":"2019-05-21T11:55:11-03:00","duration":9264,"firstTimeIn":"2019-05-21T14:55:11+00:00","phase":{"name":"Expedição"}},{"created_at":"2019-05-21T14:29:36-03:00","duration":35,"firstTimeIn":"2019-05-21T17:29:36+00:00","phase":{"name":"Cotação de frete"}},{"created_at":"2019-05-21T14:30:11-03:00","duration":512,"firstTimeIn":"2019-05-21T17:30:11+00:00","phase":{"name":"Faturamento"}},{"created_at":"2019-05-21T14:38:44-03:00","duration":335,"firstTimeIn":"2019-05-21T17:38:44+00:00","phase":{"name":"Boletos"}},{"created_at":"2019-05-21T14:44:19-03:00","duration":260,"firstTimeIn":"2019-05-21T17:44:19+00:00","phase":{"name":"Etiquetagem"}},{"created_at":"2019-05-21T14:48:40-03:00","duration":62284,"firstTimeIn":"2019-05-21T17:48:40+00:00","phase":{"name":"Pronto para coleta"}},{"created_at":"2019-05-22T08:06:44-03:00","duration":31635828,"firstTimeIn":"2019-05-22T11:06:44+00:00","phase":{"name":"Em Transito"}}],"title":"Analise de credito"}},{"node":{"assignees":{],"fields":"{"value":"21/05/2019"},{"value":"5755"},{"value":"bloco mf foto com ar \n6x300 10p\n6x250 10p"},{"value":"SEMIR"},{"value":"29.930.391/0001-25"},{"value":"30/60"},{"value":"Analise de credito"},{"value":"FABIO PEREIRA AMERICO"},{"value":"1014"},{"value":"Sim"},{"value":"Sim"},{"value":"Reprovada"},{"value":"40 BLOCOS "},{"value":"16/05/2019"},{"value":"5598"}],"id":"29073461","phases_history":I{"created_at":"2019-05-16T09:29:38-03:00","duration":1,"firstTimeIn":"2019-05-16T12:29:38+00:00","phase":{"name":"Start form"}},{"created_at":"2019-05-16T09:29:39-03:00","duration":8,"firstTimeIn":"2019-05-16T12:29:39+00:00","phase":{"name":"Solicitação"}},{"created_at":"2019-05-16T09:29:48-03:00","duration":9023,"firstTimeIn":"2019-05-16T12:29:48+00:00","phase":{"name":"Digitação"}},{"created_at":"2019-05-16T12:00:12-03:00","duration":319,"firstTimeIn":"2019-05-16T15:00:12+00:00","phase":{"name":"Analise de Crédito"}},{"created_at":"2019-05-16T12:05:31-03:00","duration":353302,"firstTimeIn":"2019-05-16T15:05:31+00:00","phase":{"name":"Bloqueado "}},{"created_at":"2019-05-20T14:13:53-03:00","duration":71278,"firstTimeIn":"2019-05-20T17:13:53+00:00","phase":{"name":"Liberado p/ Separação"}},{"created_at":"2019-05-21T10:01:52-03:00","duration":1433,"firstTimeIn":"2019-05-21T13:01:52+00:00","phase":{"name":"Separação"}},{"created_at":"2019-05-21T10:25:46-03:00","duration":5059,"firstTimeIn":"2019-05-21T13:25:46+00:00","phase":{"name":"Conferência"}},{"created_at":"2019-05-21T11:50:05-03:00","duration":311,"firstTimeIn":"2019-05-21T14:50:05+00:00","phase":{"name":"Embalagem"}},{"created_at":"2019-05-21T11:55:17-03:00","duration":9267,"firstTimeIn":"2019-05-21T14:55:17+00:00","phase":{"name":"Expedição"}},{"created_at":"2019-05-21T14:29:44-03:00","duration":53,"firstTimeIn":"2019-05-21T17:29:44+00:00","phase":{"name":"Cotação de frete"}},{"created_at":"2019-05-21T14:30:37-03:00","duration":528,"firstTimeIn":"2019-05-21T17:30:37+00:00","phase":{"name":"Faturamento"}},{"created_at":"2019-05-21T14:39:25-03:00","duration":304,"firstTimeIn":"2019-05-21T17:39:25+00:00","phase":{"name":"Boletos"}},{"created_at":"2019-05-21T14:44:29-03:00","duration":257,"firstTimeIn":"2019-05-21T17:44:29+00:00","phase":{"name":"Etiquetagem"}},{"created_at":"2019-05-21T14:48:47-03:00","duration":62279,"firstTimeIn":"2019-05-21T17:48:47+00:00","phase":{"name":"Pronto para coleta"}},{"created_at":"2019-05-22T08:06:46-03:00","duration":31635826,"firstTimeIn":"2019-05-22T11:06:46+00:00","phase":{"name":"Em Transito"}}],"title":"Analise de credito"}},{"node":{"assignees":a],"fields":}{"value":"_\"SIM\"]"},{"value":"Sim"},{"value":"aguardando pagamento da entrada"},{"value":"71 ACABADAS"},{"value":"17/04/2019"},{"value":"5458"},{"value":"VS INCOLOR AR\n\n-1,00 - 0,25 - 10\n - 0,50 - 10\n - 0,75 - 10\n - 1,00 - 09\n - 1,25 - 09\n - 1,50 - 10\n - 1,75 - 08\n - 2,00 - 05\n\nPEDIDO EM UNIDADES"},{"value":"GLAUCO"},{"value":"13.160.348/0001-98"},{"value":"n\"Não\"]"},{"value":"Entrada /30/60/90"},{"value":"Analise de credito"},{"value":"ULTRA OTICA COMERCIO DE PRODUTOS OTICOS LTDA"},{"value":"1625"},{"value":"Aprovada"},{"value":"Cliente bloqueado"},{"value":"21/05/2019"},{"value":"5751"},{"value":"Sim"}],"id":"26354540","phases_history":L{"created_at":"2019-04-17T09:59:38-03:00","duration":2,"firstTimeIn":"2019-04-17T12:59:38+00:00","phase":{"name":"Start form"}},{"created_at":"2019-04-17T09:59:41-03:00","duration":9,"firstTimeIn":"2019-04-17T12:59:41+00:00","phase":{"name":"Solicitação"}},{"created_at":"2019-05-02T14:58:21-03:00","duration":826,"firstTimeIn":"2019-05-02T17:58:21+00:00","phase":{"name":"Inclusão de preço"}},{"created_at":"2019-04-17T09:59:50-03:00","duration":2988,"firstTimeIn":"2019-04-17T12:59:50+00:00","phase":{"name":"Digitação"}},{"created_at":"2019-04-24T17:25:19-03:00","duration":68204,"firstTimeIn":"2019-04-24T20:25:19+00:00","phase":{"name":"Analise Financeira"}},{"created_at":"2019-05-02T15:22:59-03:00","duration":6293,"firstTimeIn":"2019-05-02T18:22:59+00:00","phase":{"name":"Complemento"}},{"created_at":"2019-04-17T10:49:20-03:00","duration":1047,"firstTimeIn":"2019-04-17T13:49:20+00:00","phase":{"name":"Analise de Crédito"}},{"created_at":"2019-04-17T10:55:54-03:00","duration":1242343,"firstTimeIn":"2019-04-17T13:55:54+00:00","phase":{"name":"Bloqueado "}},{"created_at":"2019-05-02T17:16:41-03:00","duration":1295875,"firstTimeIn":"2019-05-02T20:16:41+00:00","phase":{"name":"Aguard. Pagamento"}},{"created_at":"2019-05-02T17:08:15-03:00","duration":236885,"firstTimeIn":"2019-05-02T20:08:15+00:00","phase":{"name":"Liberado p/ Separação"}},{"created_at":"201 |
Page 1 / 1
Olá Thiago!
É necessário transformar essa string em uma estrutura de dados, então precisa passar por um parser antes com o json.loads.
A partir disto você pode acessar exatamente quais valores precisa com print(response.textn'data']['allCards']l'edges']), por exemplo.
Para mandar para o dataframe terá que a partir da estrutura de dados, usar o json_normalize da biblioteca pandas.
A documentação abaixo pode lhe auxiliar:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html?highlight=json
Reply
Join us in the Pipefy Community! 🚀
No account yet? Create an account
Login with your Pipefy credentials
or
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.