やりたいこと
eBIRD API の結果を使っての作業をしているとき、結果がとにかくみやすくさくっと確認したい。
戻り値は json で、中には長いテキストなども含まれていて見辛いので、苦労せずに確認したい。
HOW
まずは jq をインストール
brew install jq
APIの結果を表示する時 | jq
とパイプ。
結果
before
curl 'https://api.ebird.org/v2/product/checklist/view/S89703713'
{"projId":"EBIRD","subId":"S89703713","protocolId":"P21","locId":"L9594408","durationHrs":5.0,"allObsReported":true,"creationDt":"2021-06-06 05:55","lastEditedDt":"2021-06-12 00:35","obsDt":"2021-05-29 14:18","obsTimeValid":true,"checklistId":"CL30074","numObservers":2,"subnational1Code":"JP-08","submissionMethodCode":"EBIRD_iOS","submissionMethodVersion":"2.5.23","userDisplayName":"******","submissionMethodVersionDisp":"2.5.23","subAux":[{"subId":"S89703713","fieldName":"nocturnal","entryMethodCode":"ebird_nocturnal","auxCode":"0"}],"obs":[{"speciesCode":"spbduc","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":2,"howManyAtmost":2,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636488","howManyStr":"2","present":false},{"speciesCode":"greegr3","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":20,"howManyAtmost":20,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636489","howManyStr":"20","present":false},{"speciesCode":"integr1","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":60,"howManyAtmost":60,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636482","howManyStr":"60","present":false},{"speciesCode":"litegr1","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":60,"howManyAtmost":60,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636485","howManyStr":"60","present":false},{"speciesCode":"categr2","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":60,"howManyAtmost":60,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636490","howManyStr":"60","present":false},{"speciesCode":"chpher1","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":1,"howManyAtmost":1,"comments":"Comes to this heronry every year, always single. Wine red head and neck - no way to mistake it for anything else.","subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636483","howManyStr":"1","present":false},{"speciesCode":"bkcnih1","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":40,"howManyAtmost":40,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636486","howManyStr":"40","present":false},{"speciesCode":"blkkit2","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":1,"howManyAtmost":1,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636491","howManyStr":"1","present":false},{"speciesCode":"orrwar1","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":2,"howManyAtmost":2,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636484","howManyStr":"2","present":false},{"speciesCode":"barswa4","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":30,"howManyAtmost":30,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636481","howManyStr":"30","present":false},{"speciesCode":"jabwar","hideFlags":[],"obsDt":"2021-05-29 14:18","subnational1Code":"JP-08","howManyAtleast":2,"howManyAtmost":2,"subId":"S89703713","projId":"EBIRD","obsId":"OBS1176636487","howManyStr":"2","present":false}]}
after
curl 'https://api.ebird.org/v2/product/checklist/view/S89703713' | jq
{
"projId": "EBIRD",
"subId": "S89703713",
"protocolId": "P21",
"locId": "L9594408",
"durationHrs": 5,
"allObsReported": true,
"creationDt": "2021-06-06 05:55",
"lastEditedDt": "2021-06-12 00:35",
"obsDt": "2021-05-29 14:18",
"obsTimeValid": true,
"checklistId": "CL30074",
"numObservers": 2,
"subnational1Code": "JP-08",
"submissionMethodCode": "EBIRD_iOS",
"submissionMethodVersion": "2.5.23",
"userDisplayName": "******",
"submissionMethodVersionDisp": "2.5.23",
"subAux": [
{
"subId": "S89703713",
"fieldName": "nocturnal",
"entryMethodCode": "ebird_nocturnal",
"auxCode": "0"
}
],
"obs": [
{
"speciesCode": "spbduc",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 2,
"howManyAtmost": 2,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636488",
"howManyStr": "2",
"present": false
},
{
"speciesCode": "greegr3",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 20,
"howManyAtmost": 20,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636489",
"howManyStr": "20",
"present": false
},
{
"speciesCode": "integr1",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 60,
"howManyAtmost": 60,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636482",
"howManyStr": "60",
"present": false
},
{
"speciesCode": "litegr1",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 60,
"howManyAtmost": 60,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636485",
"howManyStr": "60",
"present": false
},
{
"speciesCode": "categr2",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 60,
"howManyAtmost": 60,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636490",
"howManyStr": "60",
"present": false
},
{
"speciesCode": "chpher1",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 1,
"howManyAtmost": 1,
"comments": "Comes to this heronry every year, always single. Wine red head and neck - no way to mistake it for anything else.",
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636483",
"howManyStr": "1",
"present": false
},
{
"speciesCode": "bkcnih1",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 40,
"howManyAtmost": 40,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636486",
"howManyStr": "40",
"present": false
},
{
"speciesCode": "blkkit2",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 1,
"howManyAtmost": 1,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636491",
"howManyStr": "1",
"present": false
},
{
"speciesCode": "orrwar1",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 2,
"howManyAtmost": 2,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636484",
"howManyStr": "2",
"present": false
},
{
"speciesCode": "barswa4",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 30,
"howManyAtmost": 30,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636481",
"howManyStr": "30",
"present": false
},
{
"speciesCode": "jabwar",
"hideFlags": [],
"obsDt": "2021-05-29 14:18",
"subnational1Code": "JP-08",
"howManyAtleast": 2,
"howManyAtmost": 2,
"subId": "S89703713",
"projId": "EBIRD",
"obsId": "OBS1176636487",
"howManyStr": "2",
"present": false
}
]
}