# Util

# getClientIDv2

  • Arguments: none

  • Returns: Promise<string>

  • Usage: Resolve a client_id for APIv2 using web scraping.

    Returns a Promise that fulfills into a string or throws an Error if no client_id could be found.

  • Example:

    import { util } from "opensoundcloud"
    
    const client_id = await util.getClientIDv2()
    console.log(client_id) //> "aaabbbcccdddeeefff00011122233344"
    

# ensureMin

  • Arguments:

    • paginated: {Object} PaginatedResponse
    • min: {number}
  • Returns: Promise<PaginatedResponse>

  • Usage: Provide a PaginatedResponse and minimum amount of items you want.

  • Example:

    // the amount of tracks you need
    const limit = 10
    
    // this example user has no tracks in the first request.
    const firstRequest = await user.tracks("space-laces", { limit })
    
    // there will be 10 or more tracks in `out.collection`
    const out = await util.ensureMin(firstRequest, limit)
    
  • See also: Ensure a minimum of returned items

Last Updated: 2/17/2021, 11:31:32 AM