      disallow any requests from other domains, or set to '*' to allow from any domain. */
     public init(agent: SQLAgent, router: Router, allowCorsOrigin: String?) {
 		self.agent = agent
-        
-        let mw = SQLAPIEndpointCORS(allowOrigin: allowCorsOrigin)
-        router.options("/api/*", middleware: mw)
-        router.get("/api/*", middleware: mw)
-        router.post("/api/*", middleware: mw)
-    
+
+		// API used by the web client
+		let mw = SQLAPIEndpointCORS(allowOrigin: allowCorsOrigin)
+		router.options("/api/*", middleware: mw)
+		router.get("/api/*", middleware: mw)
+		router.post("/api/*", middleware: mw)
 		router.get("/api", handler: self.handleIndex)
-		router.get("/api/block/:hash", handler: self.handleGetBlock)
-		router.get("/api/head", handler: self.handleGetLast)
-		router.get("/api/journal", handler: self.handleGetJournal)
-		router.get("/api/pool", handler: self.handleGetPool)
-		router.get("/api/users", handler: self.handleGetUsers)
+		router.get("/api/counter/:hash", handler: self.handleGetCounter)
         router.post("/api/query", handler: self.handleQuery)
+
+		// Debug APIs
+		router.get("/debug/block/:hash", handler: self.handleGetBlock)
+		router.get("/debug/head", handler: self.handleGetLast)
+		router.get("/debug/journal", handler: self.handleGetJournal)
+		router.get("/debug/pool", handler: self.handleGetPool)
+		router.get("/debug/users", handler: self.handleGetUsers)
         
         router.all("/", middleware: StaticFileServer(path: "./Resources"))
 	}

		}

		response.send(json: [
			"status": "ok",
			"users": users
		])
		next()
	}

	private func handleGetLast(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws {

            if let q = query as? [String: Any], let sql = q["sql"] as? String {
                let statement = try SQLStatement(sql)
                
                // Mutating statements are not executed - client needs to sign and submit a transaction for those
                if statement.isMutating {
                    _ = response.status(.notAcceptable)

					/* We do send back the SQL query as we would write it using the standard SQL dialect
					(transactions need to contain SQL that is formatted exactly following the dialect;
					sending back the SQL in that dialect saves the clients from implementing their own
					SQL parser/formatter). */
                    response.send(json: [
						"message": "Performing mutating queries through this API is not supported at this time.",
						"sql": statement.sql(dialect: SQLStandardDialect())
					])
                    try response.end()
                }
                else {
                    try self.agent.node.ledger.longest.withUnverifiedTransactions { chain in
