I'm trying to use API described here. It uses HMAC SHA512 authorization based on a secret key.
There is an example of implementation in PHP:
function bitmarket_api($method, $params = array())
{
  $key = "klucz_jawny";
  $secret = "klucz_tajny";
  $params["method"] = $method;
  $params["tonce"] = time();
  $post = http_build_query($params, "", "&");
  $sign = hash_hmac("sha512", $post, $secret);
  $headers = array(
      "API-Key: " . $key,
      "API-Hash: " . $sign,
  );
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_URL, "https://www.bitmarket.pl/api2/");
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  $ret = curl_exec($curl);
  return json_decode($ret);
}
Then I was trying to implement it in Swift:
import Alamofire
import CryptoSwift
func getRawJSON(method: String, params: [String]) -> String {
    let publicKey = "publicKeyHere"
    let secretKey = "secretKeyHere"
    let APIURL = "https://www.bitmarket.pl/api2/"
    var params = [
        "method": method,
        "tonce:": NSDate().timeIntervalSince1970
        ] as [String : Any]
    let hmac: Array<UInt8> = try! HMAC(key: secretKey.utf8.map({$0}), variant: .sha512).authenticate(params)
    var headers = [
        "API-Key": publicKey,
        "API-Hash": hmac
    ] as [String : Any]
}
As you may noticed, there is no Alamofire usage for fetching data yet because I have a problem with preparing data to send. I mean I've messed up something with CryptoSwift because I'm getting this error: Cannot convert value of type '[String : Any]' to expected argument type 'Array<UInt8>' when I'm trying to declare hmac variable.
How to solve it? 
I probably have to convert params array to Array<UInt8 somehow, but I don't know how to do that. I'm not sure is everything correct too.
Edit: Thanks to Martin R, the actual code is:
func getRawJSON(method: String, paramether: String) {
    let publicKey = "publicKeyHere"
    let secretKey = "secretKeyHere"
    let APIURL = "https://www.bitmarket.pl/api2/"
    let query = NSURLComponents()
    query.queryItems = [NSURLQueryItem(name: "method", value: method) as URLQueryItem,
                        NSURLQueryItem(name: "tonce", value: String(Int(NSDate().timeIntervalSince1970))) as URLQueryItem]
    let requestString = query.query!
    let requestData = Array(requestString.utf8)
    let params = [
        "method": method,
        "tonce:": String(Int(NSDate().timeIntervalSince1970))
        ] as [String : Any]
    let hmac: Array<UInt8> = try! HMAC(key: secretKey.utf8.map({$0}), variant: .sha512).authenticate(requestData)
    let hmacData = Data(bytes: hmac)
    let hmacString = hmacData.base64EncodedString()
    let headers = [
        "API-Key": publicKey,
        "API-Hash": hmacString
    ] as [String : String]
    Alamofire.request(APIURL, withMethod: .post, parameters: params, encoding: .url, headers: headers)
        .responseJSON { response in
        print(response)
    }
}
Unfortunately, after calling the function (getRawJSON(method: "info", paramether: "")), I'm fetching a JSON with an error:
{
error = 502;
errorMsg = "Invalid message hash";
time = 1472910139;
}
What's wrong with my hash?
 
    