Suppose we have some topological space $X$ and we somehow forgot about the topology. A friend of ours knows the topology and offers to tell us for any map $X\to Y$ into any topological space $Y$ whether it is continuous or not. As it turns out, we can use this to recover the topology on $X$ the following way:
Let $Z = \{0,1\}$ with topology $\{\varnothing, \{1\}, Z\}$. For a subset $A\subseteq X$ we have a map \begin{align} f_A : X &\longrightarrow Z\\ x &\longmapsto \begin{cases} 1 & \text{if $x\in A$,}\\ 0 &\text{if $x\notin A$.}\end{cases} \end{align} Now $f_A$ is continuous if and only if the preimages of open sets are open, since $f^{-1}(\varnothing)=\varnothing$ and $f^{-1}(Z)=X$ are open in any topology, we know that $f_A$ is continuous if and only if $f^{-1}(\{1\}) = A$ is open in $X$. Thus, given any subset $A$ in $X$ we ask our friend if $f_A$ is continous and we know if $A$ is open or not, so we recovered the topology as $$ \{\, A\subseteq X \mid \text{$f_A\colon X\to Z$ is continuous}\,\}. $$
We conclude that knowing the topology (i.e. the collection of open sets) of $X$ and being able to tell for any map $X\to Y$ if it is continuous are equivalent.
Is it somehow possible to define a topological space as a set $X$ together with some class of maps from $X$ satisfying certain properties so they turn out to be the continuous maps?
One problem here is that thinking of the class $$\{\, f:X\to Y \mid \text{$Y$ a topological space, $f$ continuous}\,\}$$ already implies we know what the topological spaces $Y$ are, so it seems we cannot use this class to define what a topological space is.
Can we do something similar though?