What is MIME type "application/sparql-query"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

The MIME type application/sparql-query identifies files that contain queries written in the SPARQL language. These files let servers and tools know they hold commands intended to retrieve or update RDF data.
SPARQL is a query language used in systems that process semantic data and linked datasets. When a file marked with this MIME type is received, the system processes it as a SPARQL query—similar to how an SQL query is handled in a relational database.
Files using this MIME type may have extensions such as RQ or SPARQL.
For more details on SPARQL and its query standard, visit the W3C SPARQL 1.1 Query Documentation.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: application/sparql-query    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="application/sparql-query">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'application/sparql-query');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What file extensions are associated with application/sparql-query?

The most common file extensions for this MIME type are .rq and .sparql. These files contain raw SPARQL query text used to retrieve information from RDF datasets. For more details on these specific extensions, you can visit our pages for .rq and .sparql.

How do I configure Apache or Nginx to serve SPARQL query files?

To ensure your web server correctly identifies SPARQL files, you must update its MIME type configuration. For Apache, add AddType application/sparql-query .rq .sparql to your .htaccess or config file. For Nginx, add application/sparql-query rq sparql; inside the types { } block in nginx.conf.

How is application/sparql-query used in HTTP POST requests?

According to the SPARQL 1.1 Protocol, this MIME type is used in the Content-Type header when sending a query directly in the body of an HTTP POST request. This method is preferred over GET requests for long queries because it avoids URL length limitations. The body of the request should contain the unencoded SPARQL query string.

What is the difference between application/sparql-query and application/sparql-update?

application/sparql-query is used for read-only operations (like SELECT, ASK, CONSTRUCT, or DESCRIBE) that do not modify the dataset. In contrast, application/sparql-update is reserved for operations that modify data, such as INSERT or DELETE. Web servers and endpoints distinguish between these to enforce security permissions regarding who can read versus write data.

Can I open .rq files in a standard web browser?

Most web browsers do not natively render .rq files and will typically ask to download them or display them as plain text. To view or edit these files effectively, you should use a dedicated semantic web tool like Protégé, or a code editor with SPARQL syntax highlighting (such as VS Code or Notepad++).

Are there security risks associated with SPARQL query files?

Yes, primarily SPARQL Injection. If a web application accepts user input and inserts it directly into a query file or string without sanitization, an attacker could manipulate the query to access unauthorized data. Always use parameterized queries or strict input validation when processing files with the application/sparql-query type.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.