# 5.4 JSON API: Web.Contents आणि Json.Document

Source: https://ravindrabagale.com/mr/powerbi/ch05-web-data-apis-and-google-sheets/5-4-json-apis-with-web-contents-and-json-document.html
Language: mr (Marathi with English technical terms)

Courier tracking, weather किंवा internal orders service सारख्या systems JSON देतात. खालील dark stores response आणि endpoint हे काल्पनिक example आहेत.

{ "stores": [
    { "storeId": "BLK-PUN-KOT-01", "area": "Kothrud",    "city": "Pune",   "lat": 18.507, "lng": 73.807 },
    { "storeId": "BLK-NGP-DHP-01", "area": "Dharampeth", "city": "Nagpur", "lat": 21.139, "lng": 79.063 } ] }

let
    Source  = Json.Document(Web.Contents("https://api.example.com",
                 [RelativePath = "v1/darkstores", Headers = [Accept = "application/json"]])),
    Stores  = Table.FromRecords(Source[stores]),
    Typed   = Table.TransformColumnTypes(Stores, {{"lat", type number}, {"lng", type number}})
in
    Typed

Power BI मधल्या steps

Get data › Web › Advanced मध्ये URL parts https://api.example.com/ आणि v1/darkstores द्या. Accept = application/json header जोडा.

Provider ने सांगितलेलं authentication निवडा: public API साठी Anonymous; अन्यथा supported Web API key, Basic किंवा Organizational account.

Record मधल्या stores समोरची List उघडा. List Tools › Transform › To Table › OK करा.

Column1 expand करा. आवश्यक fields निवडा आणि Use original column name as prefix बंद करा.

lat / lng Decimal Number ठेवा. Model मध्ये पुढे Latitude / Longitude data category द्या; chapter 15 पाहा.

API key code मध्ये ठेवू नका

Shared .pbix किंवा Advanced Editor मध्ये लिहिलेली key इतरांना वाचता येते. Connector चा credential dialog किंवा admin ने मंजूर केलेली पद्धत वापरा.

Practice

Anonymous access परवानगी देणाऱ्या public JSON API चे नियम वाचा. एक list of records table मध्ये बदला आणि data types सेट करा.

रवींद्र बागले यांची tip

सगळे JSON fields expand केले की शेकडो अनावश्यक columns होऊ शकतात. गरजेचेच fields घ्या. अनेक pages आणण्याआधी page size आणि rate limits तपासा.
