     }
     
     public func mutableRequest(forPath path: String, withQuery query: [String: String], isAuthorized authorized: Bool, withHTTPMethod httpMethod: Method) -> URLRequest? {
-        let urlString = "https://api.trakt.tv/" + path
+        let urlString = "https://\(APIBaseURL!)/" + path
         guard var components = URLComponents(string: urlString) else { return nil }
         
         if query.isEmpty == false {

                return
        }
        
        let urlString = "https://trakt.tv/oauth/token"
        let url = URL(string: urlString)
        guard var request = mutableRequestForURL(url, authorization: false, HTTPMethod: .POST) else {
            completionHandler?(.fail)

    
    // MARK: - Setup
    
    public func setClientID(staging: Bool, clientID: String, clientSecret secret: String, redirectURI: String) {
        self.staging = staging
        self.clientID = clientID
        self.clientSecret = secret
        self.redirectURI = redirectURI
        
        self.baseURL = !staging ? "trakt.tv" : "staging.trakt.tv"
        self.APIBaseURL = !staging ? "api.trakt.tv" : "api-staging.trakt.tv"
        self.oauthURL = URL(string: "https://\(baseURL!)/oauth/authorize?response_type=code&client_id=\(clientID)&redirect_uri=\(redirectURI)")
    }
    
    internal func createErrorWithStatusCode(_ statusCode: Int) -> NSError {
