일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 시트 탭 사라짐
- python
- MYSQL
- upbit
- Android
- league of legends
- MS-SQL
- Banker's
- Banker's rounding
- Aspose.cells
- 스크롤 사라짐
- CSV
- 일본여행
- 세로 스크롤 막대
- Excel
- chart.js
- 나만의 상점
- swift 화면전환
- 한글깨짐
- Kakao API Address
- Oracle
- 썸머노트
- rounding
- LEFT JOIN
- 가로 스크롤 막대
- Request.Form
- .csv
- MSSQL
- 업비트
- 초딩수학
- Today
- Total
DBA
REST API Call : Kakao API Address :https://dapi.kakao.com/v2/local/search/address.json 본문
REST API Call : Kakao API Address :https://dapi.kakao.com/v2/local/search/address.json
코볼 2023. 3. 23. 14:59Alamofire Version :
Installing Alamofire (5.6.4)
import Alamofire
func getAddress() -> Void {
let headers: HTTPHeaders = ["Authorization": "KakaoAK 발급받은 키"]
let parameters: Parameters = ["query": "서울특별시 강남구 역삼동"]
let url = "https://dapi.kakao.com/v2/local/search/address.json"
// 구조체 선언
struct SearchResult: Codable {
let documents: [Document]
let meta: Meta
}
struct Document: Codable {
let address: Address
let addressName: String
let addressType: String
let roadAddress: String?
let x: String
let y: String
enum CodingKeys: String, CodingKey {
case address
case addressName = "address_name"
case addressType = "address_type"
case roadAddress = "road_address_name"
case x
case y
}
}
struct Address: Codable {
let addressName: String
let bCode: String
let hCode: String
let mainAddressNo: String
let mountainYN: String
let region1DepthName: String
let region2DepthName: String
let region3DepthHName: String
let region3DepthName: String
let subAddressNo: String
let x: String
let y: String
enum CodingKeys: String, CodingKey {
case addressName = "address_name"
case bCode = "b_code"
case hCode = "h_code"
case mainAddressNo = "main_address_no"
case mountainYN = "mountain_yn"
case region1DepthName = "region_1depth_name"
case region2DepthName = "region_2depth_name"
case region3DepthHName = "region_3depth_h_name"
case region3DepthName = "region_3depth_name"
case subAddressNo = "sub_address_no"
case x
case y
}
}
struct Meta: Codable {
let isEnd: Bool
let pageableCount: Int
let totalCount: Int
enum CodingKeys: String, CodingKey {
case isEnd = "is_end"
case pageableCount = "pageable_count"
case totalCount = "total_count"
}
}
AF.request(url, method: .get, parameters: parameters, headers: headers).responseDecodable(of: SearchResult.self) { response in
switch response.result {
case .success(let result):
print(result)
let address = result.documents[0].address.addressName
print(address)
case .failure(let error):
print(error.localizedDescription)
}
}
}
위 함수 호출 결과
SearchResult(documents: [CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49d10).Document(address: CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49d98).Address(addressName: "서울 강남구 역삼동", bCode: "1168010100", hCode: "", mainAddressNo: "", mountainYN: "N", region1DepthName: "서울", region2DepthName: "강남구", region3DepthHName: "", region3DepthName: "역삼동", subAddressNo: "", x: "127.03306536185", y: "37.4953666908089"), addressName: "서울 강남구 역삼동", addressType: "REGION", roadAddress: nil, x: "127.03306536185", y: "37.4953666908089"), CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49d10).Document(address: CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49d98).Address(addressName: "서울 강남구 역삼1동", bCode: "", hCode: "1168064000", mainAddressNo: "", mountainYN: "N", region1DepthName: "서울", region2DepthName: "강남구", region3DepthHName: "역삼1동", region3DepthName: "", subAddressNo: "", x: "127.033201083326", y: "37.4954171091244"), addressName: "서울 강남구 역삼1동", addressType: "REGION", roadAddress: nil, x: "127.033201083326", y: "37.4954171091244"), CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49d10).Document(address: CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49d98).Address(addressName: "서울 강남구 역삼2동", bCode: "", hCode: "1168065000", mainAddressNo: "", mountainYN: "N", region1DepthName: "서울", region2DepthName: "강남구", region3DepthHName: "역삼2동", region3DepthName: "", subAddressNo: "", x: "127.046839198832", y: "37.4959639052057"), addressName: "서울 강남구 역삼2동", addressType: "REGION", roadAddress: nil, x: "127.046839198832", y: "37.4959639052057")], meta: CocoapodsTest.ViewController.(unknown context at $102c49c24).(unknown context at $102c49e2c).Meta(isEnd: true, pageableCount: 3, totalCount: 3))
서울 강남구 역삼동