Skip to main content

Command Palette

Search for a command to run...

spotify API postman으로 사용해보기

Updated
2 min read
spotify API postman으로 사용해보기

웹 API 시작하기

  1. Create an app, if you haven't done so.

  2. Request an access token.

  3. Use the access token to request the artist data.

1. CREATE AN APP 해주기

Redirect Url에 뭘 적어야 하는지 고민을 많이 했는데,
리다이렉트 URI는 Spotify API 인증 프로세스 후에 사용자가 리다이렉트될 URL을 지정하면 된다.

개발 환경에서 테스트하는 경우, 로컬 버서의 url을 사용하면 되고, 나중에 배포할 때 해당 url로 업데이트 하면 된다. http://127.0.0.1:8000/api/playlist/

2. 액세스 토큰 요청

  • Send a POST request to the token endpoint URI.

  • Add the Content-Type header set to the application/x-www-form-urlencoded value.

  • Add a HTTP body containing the Client ID and Client Secret, along with the grant_type parameter set to client_credentials

curl -X POST "https://accounts.spotify.com/api/token" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret"


postman으로 돌아가는지 확인하기

curl -X POST "https://accounts.spotify.com/api/token"

→ post 형식이고 주소는 https://accounts.spotify.com/api/token

H "Content-Type: application/x-www-form-urlencoded"

→ headers에 content-type으로 application/x-www-form-urlencoded 적어주기

-d "grant_type=client_credentials&client_id=your-client-id&client_secret=your-client-secret"

→ grant_type=client_credentials

→ client_id=your-client-id

→ client_secret=your-client-secret

이렇게 작성해주면 아래와 같은 1시간 동안 유효한 엑세스 토큰을 반환한다.


아티스트 데이터 요청하기

  1. Search the artist

  2. Click on the three dots icon from the artist profile

  3. Select Share > Copy link to artist. The Spotify ID is the value that comes right after the open.spotify.com/artist URI.

Our API call must include the access token we have just generated using the Authorization header as follows:

별다른 요청이 없기때문에 GET 방식으로 첫줄 주소 작성

BearerToken 자리에 발급받아서 나온 토큰 작성해주면 목록이 나온다.

More from this blog

s3사용 및 s3:PutBucketPolicy 권한 오류

1. S3 생성 중 정책 생성 페이지에서 s3:PutBucketPolicy 권한이 없어 오류 발생 IAM 사용이 아닌 루트 사용자 버전으로 설명 AWS IAM 콘솔 → 정책 → AdministratorAccess⁠검색→ 정책이 나타나면 사용자에 연결→ 없다면 새로운 정책 추가 없으므로 AdministratorAccess 생성 정책 생성 버튼 클릭 → JSON 탭 선택 후 아래 코드 입력 → 생성 { "Version": "2012-10-1...

Mar 12, 20252 min read9
s3사용 및 s3:PutBucketPolicy 권한 오류

챗봇과 사용자의 대화 내용이 길어질수록 llm 호출 시 토큰 수가 증가하여 응답 시간이 지연되는 문제가 발생

https://youtu.be/5soSQgVHGEA OpenAI API를 이용한 챗봇을 만들면서 대화가 길어질수록 LLM 호출 시 토큰 수 증가로 응답 시간이길어지는 문제가 발생 문제분석 여기서 생각하는 문제는 db 조회의 부하 처음 챗봇에게 부여하는 역할이 너무 긴데, 이걸 매 API 호출마다 전송함 대화 흐름을 기억하기 위해 챗봇-유저 간 대화 내용을 모두 DB에 저장한 다음 그대로 API 호출 마다 LLM에 전달함 → 모든 대화 ...

Jan 16, 20253 min read122
챗봇과 사용자의 대화 내용이 길어질수록 llm 호출 시 토큰 수가 증가하여 응답 시간이 지연되는 문제가 발생

dayeon's blog

124 posts